<commit_before>$:.unshift File.join(File.dirname(__FILE__),'../lib')
require 'rbstruct'
dev = ARGV[0]

raise Exception.new('No dev') unless dev

GptHeader = RbStruct do
  unsigned_char :signature, 8
  unsigned_int  :revision
  unsigned_int  :header_size
  unsigned_int  :crc32
  unsigned_int  :revserved
  unsigned_long :current_lba
  unsigned_long :backup_lba
  unsigned_long :first_lba
  unsigned_long :last_lba
  unsigned_char :guid, 16
  unsigned_long :partition_array_lba
  unsigned_int  :n_partition_array
  unsigned_int  :partition_entry_size
  unsigned_int  :partition_array_crc32
end

GptPartEntry = RbStruct do
  unsigned_char :part_type_guid, 16
  unsigned_char :part_guid, 16
  unsigned_long :last_lba
  unsigned_long :attributes
  unsigned_char :name, 72
end



file = open(dev, 'r+')

file.seek(512)
header = RbStruct::read_struct(file, GptHeader).first

file.seek(512*header.backup_lba)
backup = RbStruct::read_struct(file, GptHeader).first

puts "Primary header"
puts header.inspect
puts "----------------------------------------"
puts "Backup header"
puts backup.inspect
<commit_msg>updated gpt example<commit_after>$:.unshift File.join(File.dirname(__FILE__),'../lib')
require 'rbstruct'
dev = ARGV[0]

raise Exception.new('No dev') unless dev

GptHeader = RbStruct do
  unsigned_char :signature, 8
  unsigned_int  :revision
  unsigned_int  :header_size
  unsigned_int  :crc32
  unsigned_int  :revserved
  unsigned_long :current_lba
  unsigned_long :backup_lba
  unsigned_long :first_lba
  unsigned_long :last_lba
  unsigned_char :guid, 16
  unsigned_long :partition_array_lba
  unsigned_int  :n_partition_array
  unsigned_int  :partition_entry_size
  unsigned_int  :partition_array_crc32
end

GptPartEntry = RbStruct do
  unsigned_char :part_type_guid, 16
  unsigned_char :part_guid, 16
  unsigned_long :last_lba
  unsigned_long :attributes
  unsigned_char :name, 72
end



file = open(dev, 'r+')

file.seek(512)
header = GptHeader.read(file)

file.seek(512*header.backup_lba)
backup = GptHeader.read(file)

puts "Primary header"
puts header.inspect
puts "----------------------------------------"
puts "Backup header"
puts backup.inspect

{'fraction_non_alphanumeric': 0.11862835959221502, 'fraction_numerical': 0.018535681186283594, 'mean_word_length': 4.4110275689223055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '456048', 'n_tokens_mistral': 788, 'n_tokens_neox': 753, 'n_words': 168}