2121
2222import drgn
2323import sdb
24- from sdb .commands .zfs .internal import (BP_GET_TYPE , BP_GET_CHECKSUM ,
25- BP_GET_COMPRESS , BP_GET_LEVEL ,
26- BP_GET_LSIZE , BP_GET_BIRTH ,
27- BP_GET_PSIZE , BP_LOGICAL_BIRTH ,
28- BP_IS_HOLE , BP_GET_NDVAS ,
29- BP_IS_ENCRYPTED , BP_IS_GANG ,
30- BP_GET_LAYER , BP_IS_AUTHENTICATED ,
31- BP_HAS_INDIRECT_MAC_CKSUM ,
32- BP_GET_BYTEORDER , BP_GET_DEDUP ,
33- BP_IS_EMBEDDED , BP_IS_REDACTED ,
34- BP_GET_FILL , BP_GET_IV2 ,
35- DVA_IS_VALID , DVA_GET_VDEV ,
36- DVA_GET_OFFSET , DVA_GET_ASIZE ,
37- BPE_GET_ETYPE )
38-
39-
24+ from sdb .commands .zfs .internal import (
25+ BP_GET_TYPE , BP_GET_CHECKSUM , BP_GET_COMPRESS , BP_GET_LEVEL , BP_GET_LSIZE ,
26+ BP_GET_BIRTH , BP_GET_PSIZE , BP_LOGICAL_BIRTH , BP_IS_HOLE , BP_GET_NDVAS ,
27+ BP_IS_ENCRYPTED , BP_IS_GANG , BP_GET_LAYER , BP_IS_AUTHENTICATED ,
28+ BP_HAS_INDIRECT_MAC_CKSUM , BP_GET_BYTEORDER , BP_GET_DEDUP , BP_IS_EMBEDDED ,
29+ BP_IS_REDACTED , BP_GET_FILL , BP_GET_IV2 , DVA_IS_VALID , DVA_GET_VDEV ,
30+ DVA_GET_OFFSET , DVA_GET_ASIZE , BPE_GET_ETYPE )
4031
4132
4233class Blkptr (sdb .PrettyPrinter ):
@@ -61,61 +52,51 @@ class Blkptr(sdb.PrettyPrinter):
6152 names = ["blkptr" ]
6253 input_type = "blkptr_t *"
6354
64-
6555 def get_ot_name (self , bp : drgn .Object ) -> str :
66- return str (sdb .get_object (
67- "dmu_ot" )[BP_GET_TYPE (bp )].ot_name .string_ ().decode ("utf-8" ))
68-
56+ return str (sdb .get_object ("dmu_ot" )[BP_GET_TYPE (bp )].ot_name .string_ ().decode (
57+ "utf-8" ))
6958
7059 def get_checksum (self , bp : drgn .Object ) -> str :
71- checksum = sdb .get_object (
72- "zio_checksum_table" )[ BP_GET_CHECKSUM ( bp )].ci_name
60+ checksum = sdb .get_object ("zio_checksum_table" )[ BP_GET_CHECKSUM (
61+ bp )].ci_name
7362 return str (checksum .string_ ().decode ("utf-8" ))
7463
75-
7664 def get_compress (self , bp : drgn .Object ) -> str :
77- compress = sdb .get_object (
78- "zio_compress_table" )[ BP_GET_COMPRESS ( bp )].ci_name
65+ compress = sdb .get_object ("zio_compress_table" )[ BP_GET_COMPRESS (
66+ bp )].ci_name
7967 return str (compress .string_ ().decode ("utf-8" ))
8068
81-
8269 def print_hole (self , bp : drgn .Object ) -> None :
8370 print (f"HOLE [L{ BP_GET_LEVEL (bp )} { self .get_ot_name (bp )} ]" , end = ' ' )
8471 print (f"size={ BP_GET_LSIZE (bp ):#x} L birth={ BP_GET_BIRTH (bp ):#x} L" )
8572
86-
8773 def print_embedded (self , bp : drgn .Object ) -> None :
8874 print (f"EMBEDDED [L{ BP_GET_LEVEL (bp )} " , end = ' ' )
8975 print (f"{ self .get_ot_name (bp )} ]" , end = ' ' )
9076 print (f"et={ BPE_GET_ETYPE (bp )} { BP_GET_COMPRESS (bp )} " , end = ' ' )
9177 print (f"size={ BP_GET_LSIZE (bp ):#x} L/{ BP_GET_PSIZE (bp ):#x} P " , end = ' ' )
9278 print (f"birth={ BP_LOGICAL_BIRTH (bp )} L" )
9379
94-
9580 def print_redacted (self , bp : drgn .Object ) -> None :
9681 print (f"REDACTED [L{ BP_GET_LEVEL (bp )} " , end = ' ' )
9782 print (f"{ self .get_ot_name (bp )} ] size={ BP_GET_LSIZE (bp ):#x} " , end = ' ' )
9883 print (f"birth={ BP_LOGICAL_BIRTH (bp ):#x} " )
9984
100-
10185 def get_byteorder (self , bp : drgn .Object ) -> str :
10286 if BP_GET_BYTEORDER (bp ) == 0 :
10387 return "BE"
10488 return "LE"
10589
106-
10790 def get_gang (self , bp : drgn .Object ) -> str :
10891 if BP_IS_GANG (bp ):
10992 return "gang"
11093 return "contiguous"
11194
112-
11395 def get_dedup (self , bp : drgn .Object ) -> str :
11496 if BP_GET_DEDUP (bp ):
11597 return "dedup"
11698 return "unique"
11799
118-
119100 def get_crypt (self , bp : drgn .Object ) -> str :
120101 if BP_IS_ENCRYPTED (bp ):
121102 return "encrypted"
@@ -125,7 +106,6 @@ def get_crypt(self, bp: drgn.Object) -> str:
125106 return "indirect-MAC"
126107 return "unencrypted"
127108
128-
129109 def pretty_print (self , objs : Iterable [drgn .Object ]) -> None :
130110 copyname = ['zero' , 'single' , 'double' , 'triple' ]
131111 copies = 0
0 commit comments