File_Fstab
[ class tree: File_Fstab ] [ index: File_Fstab ] [ all elements ]

Source for file example.php

Documentation is available at example.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 3.0 of the PHP license,       |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available through the world-wide-web at the following url:           |
  11. // | http://www.php.net/license/3_0.txt.                                  |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Author: Ian Eure <ieure@php.net>                                     |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: example.php 157959 2004-05-04 19:50:01Z ieure $
  20.  
  21. require_once 'File/Fstab.php';
  22.  
  23. // Get an instance for the system's fstab.
  24. $sysTab File_Fstab::singleton('/etc/fstab');
  25.  
  26. // Get the entry for the root partition.
  27. $rootEnt &$sysTab->getEntryForPath('/');
  28.  
  29.  
  30. // See how error handling is set.
  31. if ($rootEnt->hasMountOption('errors')) {
  32.     print "Error handling for / is: ".$rootEnt->mountOptions['errors']."\n";
  33. else {
  34.     print "Error handling for / is undefined.\n";
  35. }
  36.  
  37. // Change fstype for /
  38. print "Chanking fstype for ".$rootEnt->getDeviceUUIDOrLabel()." (mounted on ".$rootEnt->getMountPoint().") to reiserfs\n";
  39. $rootEnt->fsType = 'reiserfs';
  40.  
  41. // Create a new entry.
  42. print "Adding entry for CD-ROM\n";
  43. $ent = new File_Fstab_Entry;
  44. $ent->device = '/dev/cdrom';
  45. $ent->mountPoint = '/cdrom';
  46. $ent->fsType = 'iso9660';
  47. $ent->setMountOption('user');
  48.  
  49. // Add the entry
  50. $sysTab->addEntry(&$ent);
  51.  
  52. // Write to a temp file.
  53. print "Saving modified fstab to /tmp/newtab\n";
  54. $res $sysTab->save('/tmp/newtab');
  55. if (PEAR::isError($res)) {
  56.     die($res->getMessage()."\n");
  57. }
  58.  
  59. ?>

Documentation generated on Mon, 11 Mar 2019 15:39:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.