A Python library for creating and managing block devices with FUSE filesystem support. Provides persistent object storage with compression options and real-time synchronization capabilities.
- Block Device Operations: C++ extension for efficient block device operations
- FUSE Filesystem: Mount block devices as user-space filesystems
- Persistent Storage: Multiple storage backends including disk-based and compressed storage
- Real-time Sync: Network synchronization for distributed applications
- Python Integration: Seamless integration with Python applications
git clone https://github.com/Omena0/blockdevice.git
cd blockdevice
pip install .
from blockdevice import BlockDevice, DiskObject
# Create a block device
dev = BlockDevice("/path/to/device", dolphin=True)
# Create persistent storage
storage = DiskObject("data.pkl")
storage['key'] = 'value'
print(storage['key']) # 'value'
dev.start(True) # Start FUSE filesystem
from blockdevice import CompressedDiskObject
# Create compressed persistent storage
storage = CompressedDiskObject("data.zst", compression_level=10)
storage['large_data'] = 'x' * 10000 # Automatically compressed
from blockdevice import NetworkObject
# Create synchronized object (connects to server or becomes server)
sync_obj = NetworkObject('localhost', 8080)
sync_obj['shared_data'] = 'available on all connected instances'
The library consists of several key components:
- BlockDevice: C++ extension providing low-level block operations
- Storage Objects:
Object
: Abstract base class for persistent objectsDiskObject
: Pickle-based disk storageCompressedDiskObject
: Zstd-compressed disk storageNetworkObject
: Real-time synchronized storage
- FUSE Integration:
BlockDeviceFUSE
class for filesystem mounting
git clone https://github.com/Omena0/blockdevice.git
cd blockdevice
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
pip install -e .
# Run all tests
pytest
# Run with coverage
pytest --cov=blockdevice --cov-report=html
# Run specific test file
pytest tests/test_utils.py
# Build the C++ extension
python setup.py build_ext --inplace
# Build distribution
python setup.py sdist bdist_wheel
See the examples/
directory for sample applications:
compressed.py
: Filesystem implementation with compressionnetwork/
: Client-server examples
BlockDevice(path: str, dolphin: bool = False)
Core block device operations.
DiskObject(path: str, default_value=None)
Persistent dictionary stored as pickle file.
CompressedDiskObject(path: str, default_value=None, compression_level=5)
Compressed persistent storage using zstd.
NetworkObject(host: str, port: int = None, default_value=None)
Real-time synchronized storage across network.
BlockDeviceFUSE(block_device)
FUSE filesystem operations handler.
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
See COPYING.md for license information.
- Omena0 ([email protected])