Tie::Mounted - Tie a mounted node to an array
use Tie::Mounted; tie @files, 'Tie::Mounted', '/backup', '-v'; print $files[-1]; untie @files;
This module ties files (and directories) of a mount point to an array by invoking the system commands mount and umount; mount is invoked when a former attempt to tie an array is being committed, umount when a tied array is to be untied. Suitability is therefore limited and suggests a rarely used node (such as /backup, for example).
mount
umount
The mandatory parameter consists of the node (or: mount point) to be mounted (/backup - as declared in /etc/fstab); options to mount may be subsequently passed (-v). Device names and mount options (-a,-A,-d) will be discarded for safety's sake.
-v
-a,-A,-d
Default paths to mount and umount may be overriden by setting accordingly either $Tie::Mounted::MOUNT_BIN or $Tie::Mounted::UMOUNT_BIN. If one of them does not exist at the predefined path, a which() will be performed to determine the actual path.
$Tie::Mounted::MOUNT_BIN
$Tie::Mounted::UMOUNT_BIN
which()
If $Tie::Mounted::NO_FILES is set to a true value, a bogus array with zero files will be tied.
$Tie::Mounted::NO_FILES
There are no security restrictions; it is recommended to adjust filesystem permissions to prevent malicious use.
Tie::Mounted is Linux/UNIX centered (due to the fstab file and the (u)mount binary requirement) and will most likely not work on other platforms.
Tie::Mounted
(u)mount
The tied array is read-only.
Files within the tied array are statically tied.
Tests that test the base functionality are completely missing due to an environment that most likely cannot be adequately simulated.
"tie" in perlfunc, fstab(5), mount(8), umount(8)
Steven Schubiger <schubiger@cpan.org>
This program is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
See http://dev.perl.org/licenses/
To install Tie::Mounted, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::Mounted
CPAN shell
perl -MCPAN -e shell install Tie::Mounted
For more information on module installation, please visit the detailed CPAN module installation guide.