{"id":21236679,"url":"https://github.com/maxg87/storage-device-managers","last_synced_at":"2025-10-04T10:48:10.580Z","repository":{"id":175672888,"uuid":"654098776","full_name":"MaxG87/storage-device-managers","owner":"MaxG87","description":null,"archived":false,"fork":false,"pushed_at":"2025-07-02T09:19:14.000Z","size":1151,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-25T16:49:08.581Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaxG87.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-06-15T11:38:08.000Z","updated_at":"2025-07-02T09:19:01.000Z","dependencies_parsed_at":"2023-12-22T11:01:36.549Z","dependency_job_id":null,"html_url":"https://github.com/MaxG87/storage-device-managers","commit_stats":null,"previous_names":["maxg87/storage-device-managers"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/MaxG87/storage-device-managers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxG87%2Fstorage-device-managers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxG87%2Fstorage-device-managers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxG87%2Fstorage-device-managers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxG87%2Fstorage-device-managers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaxG87","download_url":"https://codeload.github.com/MaxG87/storage-device-managers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaxG87%2Fstorage-device-managers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278302558,"owners_count":25964520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-21T00:13:20.102Z","updated_at":"2025-10-04T10:48:10.554Z","avatar_url":"https://github.com/MaxG87.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![Imports: isort](https://img.shields.io/badge/%20imports-isort-%231674b1?style=flat\u0026labelColor=ef8336)](https://pycqa.github.io/isort/)\n[![Checked with mypy](http://www.mypy-lang.org/static/mypy_badge.svg)](http://mypy-lang.org/)\n[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)\n\n# Storage Device Managers - Helpful context managers for managing decryption and mounts of storage devices\n\n## Overview\n\nThe `storage_device_managers` module provides a set of utilities to manage\nencrypted storage devices, handle BtrFS mounts, and perform file system\noperations in a secure and structured way. It is designed to support common\nstorage-related tasks such as:\n\n- Decrypting and mounting encrypted devices\n- Managing BtrFS compression settings\n- Creating and removing symbolic links with root privileges\n- Formatting and encrypting devices\n- Changing file ownership securely\n\n## Features\n\n- **Device Decryption \u0026 Encryption**: Easily decrypt and encrypt storage devices using `cryptsetup`.\n- **BtrFS Mount Management**: Mount and unmount BtrFS file systems with optional compression settings.\n- **Symbolic Link Handling**: Create and remove symbolic links with elevated permissions.\n- **File System Operations**: Format devices with BtrFS, manage ownership, and check mount status.\n- **Secure Passphrase Handling**: Automatically generate safe passwords for encryption.\n\n## Usage\n\n### Decrypting and Mounting a Device\n```python\nfrom pathlib import Path\nfrom storage_device_managers import decrypted_device, mounted_device\n\n# Decrypt and mount a device\nwith decrypted_device(Path(\"/dev/sdb1\"), \"cat /path/to/password-file\") as dev:\n    with mounted_device(dev) as mount_point:\n        print(f\"Device mounted at {mount_point}\")\n```\n\n### Encrypting a Device\n```python\nfrom pathlib import Path\nfrom storage_device_managers import encrypt_device\n\nuuid = encrypt_device(Path(\"/dev/sdb1\"), \"cat /path/to/password-file\")\nprint(f\"Device encrypted with UUID: {uuid}\")\n```\n\n### Creating a Symbolic Link\n```python\nfrom pathlib import Path\nfrom storage_device_managers import symbolic_link\n\nsrc = Path(\"/path/to/source\")\ndest = Path(\"/path/to/destination\")\n\nwith symbolic_link(src, dest) as link:\n    print(f\"Symbolic link created at {link}\")\n```\n\n## API Reference\n\n### Context Managers\n- `decrypted_device(device: Path, pass_cmd: str) -\u003e Iterator[Path]`\n  - Decrypts a device using `cryptsetup` and returns a context-managed path.\n- `mounted_device(device: Path, compression: Optional[ValidCompressions] = None) -\u003e Iterator[Path]`\n  - Mounts a BtrFS device with optional compression settings.\n- `symbolic_link(src: Path, dest: Path) -\u003e Iterator[Path]`\n  - Creates and removes a symbolic link with root privileges.\n\n### Utility Functions\n- `mount_btrfs_device(device: Path, mount_dir: Path, compression: Optional[ValidCompressions] = None) -\u003e None`\n- `is_mounted(device: Path) -\u003e bool`\n- `get_mounted_devices() -\u003e Mapping[str, Mapping[Path, frozenset[str]]]`\n- `unmount_device(device: Path) -\u003e None`\n- `open_encrypted_device(device: Path, pass_cmd: str) -\u003e Path`\n- `close_decrypted_device(device: Path) -\u003e None`\n- `encrypt_device(device: Path, password_cmd: str) -\u003e UUID`\n- `mkfs_btrfs(device: Path) -\u003e None`\n- `generate_passcmd() -\u003e str`\n- `chown(file_or_folder: Path, user: Union[int, str], group: Optional[Union[int, str]] = None, *, recursive: bool) -\u003e None`\n\n## Contributing\nContributions are welcome! Please submit issues and pull requests via GitHub.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxg87%2Fstorage-device-managers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxg87%2Fstorage-device-managers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxg87%2Fstorage-device-managers/lists"}