objectfs API¶
Note
The code documentation is in progress. Right now the best documentation is the code itself.
pyvfs.vfs – abstract VFS layer¶
Internal VFS protocol. You can use this module to build your own filesystems.
-
class
pyvfs.vfs.
Storage
(inode=<class 'pyvfs.vfs.Inode'>, **kwarg)[source]¶ High-level storage insterface. Implements a simple protocol for the file management and file lookup dictionary.
Should be provided with root ‘inode’ class on init. The ‘inode’ class MUST support the interface… that should be defined :)
pyvfs.utils – utility classes¶
Utility classes for VFS
-
class
pyvfs.utils.
Server
(fs=None)[source]¶ The main interface to create and start a filesystem.
The filesystem will be exported with the protocol you will choose. Supported protocols now are
9p
andfuse
. For9p
you should have py9p installed, forfuse
, respectively, fuse-python binding. With9p
you will be able to mount the FS with mount(8) or with any other 9p implementation:mount -t 9p -o ro,port=10001 127.0.0.1 /mnt/debugfs
In the case of
fuse
protocol, the FS will be mounted immediately with the script startup. You can configure the behaviour with environment variables:PYVFS_PROTO –
9p
(default) orfuse
PYVFS_PORT – tcp port for TCP sockets and access mode for UNIX sockets (9p only, default: 10001)
PYVFS_ADDRESS – IPv4 address, use 0.0.0.0 to allow public access (9p only, default: 127.0.0.1)
PYVFS_MOUNTPOINT – the mountpoint (fuse only, default: ./mnt)
PYVFS_DEBUG – turn on stderr debug output of the FS protocol
PYVFS_LOG – create /log inode
PYVFS_ALLOW_ROOT – allow root to access the mountpoint (fuse only, default: False)
PYVFS_ALLOW_OTHER – allow other users to access the mountpoint, requires
user_allow_other
in/etc/fuse.conf
(fuse only, default: False)AUTHMODE – authentication mode for 9p, can be
pki
(9p only, default: none)KEYFILES – map of user public key files (9p only, default: none)
Warning
No authentication for 9p is used in this library yet. Do not expose the socket to the public access unless you completely understand what are you doing.
The typical code should look like that:
from pyvfs.utils import Server server = Server() server.start()
To run server in the backgroung, use
start()
, in the foreground –run()
method.If you want to use some custom storage, you can derive a class from pyvfs.vfs.Storage, and use an instance of it as an argument in the Server constructor:
from somewhere import CustomStorage from pyvfs.utils import Server server = Server(CustomStorage()) server.start()
-
class
pyvfs.utils.
indexInode
(name, parent=None, mode=0, storage=None, **kwarg)[source]¶ An inode that lists full storage file index. Can be used for debugging purposes.