-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
110 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
LBA 0 is the protective MBR | ||
LBA 1 is where the header starts | ||
Byte 0 - 7 (Signature) "EFI PART" or 45h 46h 49h 20h 50h 41h 52h | ||
Byte 8 - 11 (Revision) "1.0" or 00h 00h 01h 00h | ||
Byte 12 - 15 (Header size LE) 5Ch 00h 00h 00h (92 bytes) | ||
Byte 16 - 19 CRC32 of header from 0 to 15 | ||
Byte 20 - 23 reserved (must be zero) | ||
Byte 24 - 31 Current LBA location | ||
Byte 32 - 39 Backup LBA location | ||
LBA 2 - 33 partitions | ||
""" | ||
from pygpt_disk.disk import Disk | ||
|
||
|
||
class Table: | ||
_header_sig = b"\x45\x46\x49\x20\x50\x41\x52\x54" | ||
|
||
def __init__(self, disk: Disk): | ||
self.disk = disk | ||
|
||
def create(self): | ||
"""Create blank GPT Table Header""" | ||
# move to LBA 1 | ||
self.disk.buffer.seek(self.disk.sector_size - 1) | ||
self.disk.buffer.write(Table._header_sig) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from pygpt_disk import table, disk | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def fresh_disk(tmp_path): | ||
image_path = tmp_path / "table-test.img" | ||
return disk.Disk(8 * 1024 * 1024, image_path) | ||
|
||
|
||
def test_init(fresh_disk: disk.Disk): | ||
t = table.Table(fresh_disk) | ||
t.create() | ||
t.disk.buffer.seek(512 - 1) | ||
assert t.disk.buffer.read(8) == b"EFI PART" |
Binary file not shown.