GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — python-scsi/examples/read16.py at master · python-scsi/python-scsi

Expand file tree

/

read16.py

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
50 lines (39 loc) · 1.5 KB
/

read16.py

Copy path

File metadata and controls

50 lines (39 loc) · 1.5 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env python
# SPDX-FileCopyrightText: 2014 The python-scsi Authors
#
# SPDX-License-Identifier: LGPL-2.1-or-later
# coding: utf-8
import sys
from pyscsi.pyscsi.scsi import SCSI
from pyscsi.utils import init_device
def ba_to_int(ba):
return sum(b for b in ba)
def ba_to_hex(ba):
result = ""
for b in ba:
result += hex(b)[2:]
return result
def main(device):
with SCSI(device, blocksize=512) as s:
r = s.read16(
1,
1,
).datain
print("Read16 - GPT Header")
print("==========================================\n")
print("signature: %s" % r[:8])
print("revision: %.1f" % float(ba_to_int(r[8:12])))
print("header size: %s byte" % ba_to_int(r[12:16]))
print("crc32 of header: %s" % ba_to_hex(r[16:20]))
print("reserved: %s" % ba_to_int(r[20:24]))
print("current LBA: %s" % ba_to_int(r[24:32]))
print("backup LBA: %s" % ba_to_int(r[32:40]))
print("first usable LBA for partitions: %s" % ba_to_int(r[40:48]))
print("last usable LBA: %s" % ba_to_int(r[48:56]))
print("Disk GUID: %s" % ba_to_hex(r[56:72]))
print("Starting LBA of array of partition entries: %s" % ba_to_int(r[72:80]))
print("number of partition entries in array: %s" % ba_to_int(r[80:84]))
print("size of a single partition entry: %s" % ba_to_int(r[84:88]))
print("crc32 of header: %s" % ba_to_hex(r[88:92]))
if __name__ == "__main__":
main(init_device(sys.argv[1]))
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.