NAME
Filesys::POSIX::Mount - Exposes VFS mounting functionality to Filesys::POSIX
DESCRIPTION
Filesys::POSIX::Mount
is a mixin module imported into the Filesys::POSIX namespace by said module that provides a frontend to the internal VFS. Rather than dealing in terms of mount point vnodes as Filesys::POSIX::VFS does, the system calls provided in this module deal in terms of pathnames.
SYSTEM CALLS
$fs->mount($dev, $path, %opts)
-
Attach the filesystem device,
$dev
, to the directory inode specified by$path
. The%opts
hash can be used to pass mount options to the initialization routines for the device object to be mounted; these options are passed to the$dev->init()
routine that said filesystem device implements.The filesystem mount record is kept in an ordered list by the VFS, and can be retrieved later using the
$fs->statfs
, or$fs->mountlist
system calls. $fs->unmount($path)
-
Attempts to unmount a filesystem mounted at the directory pointed to by
$path
, performing a number of sanity checks to ensure the safety of the current operation. The following checks are made:- The directory inode is retrieved using
$fs->stat
. - Using
Filesys::POSIX::VFS->statfs
, with the directory inode passed, the VFS is queried to determine if the location given has a filesystem mounted at all. If so, the mount record is kept for reference for the next series of checks. - The file descriptor table is scanned for open files whose inodes exist on the device found for the mount record queried in the previous step by the VFS. An EBUSY exception is thrown when matching file descriptors are found.
- The current working directory is checked to ensure it is not a reference to a directory inode associated with the mounted device. An EBUSY exception is thrown if the current directory is on the same device that is to be unmounted.
- The directory inode is retrieved using
$fs->statfs($path)
-
Returns the mount record for the device associated with the inode specified by $path. The inode is found using
$fs->stat
, then queried for byFilesys::POSIX::VFS->statfs
. $fs->fstatfs($fd)
-
Returns the mount record for the device associated with the inode referenced by the open file descriptor,
$fd
. The inode is found using$fs->fstat
, then queried for byFilesys::POSIX::VFS->statfs
. $fs->mountlist
-
Returns a list of records for each filesystem currently mounted, in the order in which they were mounted.
ANATOMY OF A MOUNT RECORD
Mount records are created internally by Filesys::POSIX::VFS->mount
, and are stored as anonymous HASHes. They contain the following attributes:
mountpoint
-
Reference to the directory inode (or vnode in the case of multiple filesystems mounted in the same logical location) the filesystem is mounted to.
root
-
Reference to the mounted filesystem's root directory inode. This is never a vnode.
special
-
The value of the
special
flag specified in a call to$fs->mount
. When no value is specified, the value stored is equal toref $dev
. dev
-
A reference to the filesystem device object that was mounted by
$fs->mount
. type
-
A lowercase string formed by chopping all but the last item in a Perl fully qualified package name corresponding to the type of the device mounted. For instance, an instance of Filesys::POSIX::Mem mounted will result in a value of
'mem'
. path
-
The true, original, and sanitized path of the mount point specified by
$fs->mount
. vnode
-
A VFS inode created by
Filesys::POSIX::VFS::Inode->new
, containing most attributes of the mounted device's root inode, but with a parent pointing to the mount point inode's parent. flags
-
A copy of the options passed to
$fs->mount
, minus thespecial
option.
AUTHOR
Written by Xan Tronix <xan@cpan.org>
CONTRIBUTORS
COPYRIGHT
Copyright (c) 2014, cPanel, Inc. Distributed under the terms of the Perl Artistic license.