Bcachefs¶
-
class
bcachefs.bcachefs.Bcachefs(path: str, mode: str = 'rb')[source]¶ Opens a Bcachefs disk image for reading
- path: str
- path to the disk image
>>> with Bcachefs(path_to_file, 'r') as image: ... with image.open('dir/subdir/file2', 'rb') as f: ... data = f.read() ... print(data.decode('utf-8')) File content 2
-
closed¶ Is current image closed
-
find_dirent(path: str = None) → bcachefs.bcachefs.DirEnt[source]¶ Resolve a path to its directory entry, returns none if it was not found
-
ls(path: [<class 'str'>, <class 'bcachefs.bcachefs.DirEnt'>] = None)[source]¶ Show the files inside a given directory
-
namelist()[source]¶ Returns a list of files contained by this archive
Added for parity with Zipfile interface
>>> with Bcachefs(path_to_file, 'r') as image: ... print(image.namelist()) ['file1', 'n09332890/n09332890_29876.JPEG', 'dir/subdir/file2', 'n04467665/n04467665_63788.JPEG', 'n02033041/n02033041_3834.JPEG', 'n02445715/n02445715_16523.JPEG', 'n04584207/n04584207_7936.JPEG']
-
open(name: [<class 'str'>, <class 'int'>], mode: str = 'rb', encoding: str = 'utf-8')[source]¶ Open a file inside the image for reading
- name: str, int
- Path to a file or inode integer
- mode: str
- reading mode rb (bytes)
- encoding: str
- string encoding to use, defaults to utf-8
FileNotFoundError when opening an file that does not exist
-
path¶ Path of the current image
-
size¶ Size of the current image
-
class
bcachefs.bcachefs.BcachefsIter(fs: <sphinx.ext.autodoc.importer._MockObject object at 0x7f0b39bd8590>, t: int = 2)[source]¶
-
class
bcachefs.bcachefs.BcachefsIterDirEnt(fs: <sphinx.ext.autodoc.importer._MockObject object at 0x7f0b39bd8590>)[source]¶ Iterates over bcachefs dirent btree
-
class
bcachefs.bcachefs.BcachefsIterExtent(fs: <sphinx.ext.autodoc.importer._MockObject object at 0x7f0b39bd8590>)[source]¶ Iterates over bcachefs extend btree
-
class
bcachefs.bcachefs.BcachefsIterInode(fs: <sphinx.ext.autodoc.importer._MockObject object at 0x7f0b39bd8590>)[source]¶ Iterates over bcachefs inode btree
-
class
bcachefs.bcachefs.Cursor(path: [<class 'str'>, <class 'bcachefs.bcachefs.Bcachefs'>], extents_map: dict, inodes_ls: dict, inodes_tree: dict)[source]¶ -
-
pwd¶
-
-
class
bcachefs.bcachefs.DirEnt(parent_inode: int = 0, inode: int = 0, type: int = 0, name: str = '') → None[source]¶ Bcachefs directory entry
- parent_inode: int
- inode of the parent entry (directory)
- inode: int
- inode of the current entry
- type: int
- file (8) or directory (4)
- name: str
- name of current entry (file or directory)
-
inode= 0¶
-
is_dir¶
-
is_file¶
-
name= ''¶
-
parent_inode= 0¶
-
type= 0¶
-
class
bcachefs.bcachefs.Extent(inode: int = 0, file_offset: int = 0, offset: int = 0, size: int = 0) → None[source]¶ Specify the location of an extent of a file inside the disk image
- inode: int
- inode of the file
- file_offset: int
- position of the extent in the logical file
- offset: int
- position inside the disk image where the extent starts
- size: int
- size of the extent
-
file_offset= 0¶
-
inode= 0¶
-
offset= 0¶
-
size= 0¶