diff --git a/blkid/internal/cstruct/cstruct.go b/blkid/internal/cstruct/cstruct.go index d441a7f..87d1658 100644 --- a/blkid/internal/cstruct/cstruct.go +++ b/blkid/internal/cstruct/cstruct.go @@ -85,23 +85,33 @@ func main() { comment = name } - g.Printf("// Get_%s returns %s.\n", name, comment) - switch typ { case "uint64_t": + g.Printf("// Get_%s returns %s.\n", name, comment) g.Printf("func (s %s) Get_%s() uint64 {\nreturn binary.%s.Uint64(s[%d:%d])\n}\n", structName, name, endianness, size, size+8) + g.Printf("// Put_%s sets %s.\n", name, comment) + g.Printf("func (s %s) Put_%s(v uint64) {\nbinary.%s.PutUint64(s[%d:%d], v)\n}\n", structName, name, endianness, size, size+8) size += 8 case "uint32_t": + g.Printf("// Get_%s returns %s.\n", name, comment) g.Printf("func (s %s) Get_%s() uint32 {\nreturn binary.%s.Uint32(s[%d:%d])\n}\n", structName, name, endianness, size, size+4) + g.Printf("// Put_%s sets %s.\n", name, comment) + g.Printf("func (s %s) Put_%s(v uint32) {\nbinary.%s.PutUint32(s[%d:%d], v)\n}\n", structName, name, endianness, size, size+4) size += 4 case "uint16_t": + g.Printf("// Get_%s returns %s.\n", name, comment) g.Printf("func (s %s) Get_%s() uint16 {\nreturn binary.%s.Uint16(s[%d:%d])\n}\n", structName, name, endianness, size, size+2) + g.Printf("// Put_%s sets %s.\n", name, comment) + g.Printf("func (s %s) Put_%s(v uint16) {\nbinary.%s.PutUint16(s[%d:%d], v)\n}\n", structName, name, endianness, size, size+2) size += 2 case "uint8_t", "unsigned char": + g.Printf("// Get_%s returns %s.\n", name, comment) g.Printf("func (s %s) Get_%s() byte {\nreturn s[%d]\n}\n", structName, name, size) + g.Printf("// Put_%s sets %s.\n", name, comment) + g.Printf("func (s %s) Put_%s(v byte) {\ns[%d] = v\n}\n", structName, name, size) size++ } @@ -121,6 +131,8 @@ func main() { g.Printf("// Get_%s returns %s.\n", name, comment) g.Printf("func (s %s) Get_%s() []byte {\nreturn s[%d:%d]\n}\n", structName, name, size, size+fieldSize) + g.Printf("// Put_%s sets %s.\n", name, comment) + g.Printf("func (s %s) Put_%s(v []byte) {\ncopy(s[%d:%d], v)\n}\n", structName, name, size, size+fieldSize) size += fieldSize case uintSliceRe.MatchString(line): diff --git a/blkid/internal/filesystems/ext/superblock.go b/blkid/internal/filesystems/ext/superblock.go index 0104a1e..3113b06 100644 --- a/blkid/internal/filesystems/ext/superblock.go +++ b/blkid/internal/filesystems/ext/superblock.go @@ -18,255 +18,510 @@ func (s SuperBlock) Get_s_inodes_count() uint32 { return binary.LittleEndian.Uint32(s[0:4]) } +// Put_s_inodes_count sets s_inodes_count. +func (s SuperBlock) Put_s_inodes_count(v uint32) { + binary.LittleEndian.PutUint32(s[0:4], v) +} + // Get_s_blocks_count returns s_blocks_count. func (s SuperBlock) Get_s_blocks_count() uint32 { return binary.LittleEndian.Uint32(s[4:8]) } +// Put_s_blocks_count sets s_blocks_count. +func (s SuperBlock) Put_s_blocks_count(v uint32) { + binary.LittleEndian.PutUint32(s[4:8], v) +} + // Get_s_r_blocks_count returns s_r_blocks_count. func (s SuperBlock) Get_s_r_blocks_count() uint32 { return binary.LittleEndian.Uint32(s[8:12]) } +// Put_s_r_blocks_count sets s_r_blocks_count. +func (s SuperBlock) Put_s_r_blocks_count(v uint32) { + binary.LittleEndian.PutUint32(s[8:12], v) +} + // Get_s_free_blocks_count returns s_free_blocks_count. func (s SuperBlock) Get_s_free_blocks_count() uint32 { return binary.LittleEndian.Uint32(s[12:16]) } +// Put_s_free_blocks_count sets s_free_blocks_count. +func (s SuperBlock) Put_s_free_blocks_count(v uint32) { + binary.LittleEndian.PutUint32(s[12:16], v) +} + // Get_s_free_inodes_count returns s_free_inodes_count. func (s SuperBlock) Get_s_free_inodes_count() uint32 { return binary.LittleEndian.Uint32(s[16:20]) } +// Put_s_free_inodes_count sets s_free_inodes_count. +func (s SuperBlock) Put_s_free_inodes_count(v uint32) { + binary.LittleEndian.PutUint32(s[16:20], v) +} + // Get_s_first_data_block returns s_first_data_block. func (s SuperBlock) Get_s_first_data_block() uint32 { return binary.LittleEndian.Uint32(s[20:24]) } +// Put_s_first_data_block sets s_first_data_block. +func (s SuperBlock) Put_s_first_data_block(v uint32) { + binary.LittleEndian.PutUint32(s[20:24], v) +} + // Get_s_log_block_size returns s_log_block_size. func (s SuperBlock) Get_s_log_block_size() uint32 { return binary.LittleEndian.Uint32(s[24:28]) } +// Put_s_log_block_size sets s_log_block_size. +func (s SuperBlock) Put_s_log_block_size(v uint32) { + binary.LittleEndian.PutUint32(s[24:28], v) +} + // Get_s_magic returns s_magic. func (s SuperBlock) Get_s_magic() []byte { return s[56:58] } +// Put_s_magic sets s_magic. +func (s SuperBlock) Put_s_magic(v []byte) { + copy(s[56:58], v) +} + // Get_s_state returns s_state. func (s SuperBlock) Get_s_state() uint16 { return binary.LittleEndian.Uint16(s[58:60]) } +// Put_s_state sets s_state. +func (s SuperBlock) Put_s_state(v uint16) { + binary.LittleEndian.PutUint16(s[58:60], v) +} + // Get_s_errors returns s_errors. func (s SuperBlock) Get_s_errors() uint16 { return binary.LittleEndian.Uint16(s[60:62]) } +// Put_s_errors sets s_errors. +func (s SuperBlock) Put_s_errors(v uint16) { + binary.LittleEndian.PutUint16(s[60:62], v) +} + // Get_s_minor_rev_level returns s_minor_rev_level. func (s SuperBlock) Get_s_minor_rev_level() uint16 { return binary.LittleEndian.Uint16(s[62:64]) } +// Put_s_minor_rev_level sets s_minor_rev_level. +func (s SuperBlock) Put_s_minor_rev_level(v uint16) { + binary.LittleEndian.PutUint16(s[62:64], v) +} + // Get_s_lastcheck returns s_lastcheck. func (s SuperBlock) Get_s_lastcheck() uint32 { return binary.LittleEndian.Uint32(s[64:68]) } +// Put_s_lastcheck sets s_lastcheck. +func (s SuperBlock) Put_s_lastcheck(v uint32) { + binary.LittleEndian.PutUint32(s[64:68], v) +} + // Get_s_checkinterval returns s_checkinterval. func (s SuperBlock) Get_s_checkinterval() uint32 { return binary.LittleEndian.Uint32(s[68:72]) } +// Put_s_checkinterval sets s_checkinterval. +func (s SuperBlock) Put_s_checkinterval(v uint32) { + binary.LittleEndian.PutUint32(s[68:72], v) +} + // Get_s_creator_os returns s_creator_os. func (s SuperBlock) Get_s_creator_os() uint32 { return binary.LittleEndian.Uint32(s[72:76]) } +// Put_s_creator_os sets s_creator_os. +func (s SuperBlock) Put_s_creator_os(v uint32) { + binary.LittleEndian.PutUint32(s[72:76], v) +} + // Get_s_rev_level returns s_rev_level. func (s SuperBlock) Get_s_rev_level() uint32 { return binary.LittleEndian.Uint32(s[76:80]) } +// Put_s_rev_level sets s_rev_level. +func (s SuperBlock) Put_s_rev_level(v uint32) { + binary.LittleEndian.PutUint32(s[76:80], v) +} + // Get_s_def_resuid returns s_def_resuid. func (s SuperBlock) Get_s_def_resuid() uint16 { return binary.LittleEndian.Uint16(s[80:82]) } +// Put_s_def_resuid sets s_def_resuid. +func (s SuperBlock) Put_s_def_resuid(v uint16) { + binary.LittleEndian.PutUint16(s[80:82], v) +} + // Get_s_def_resgid returns s_def_resgid. func (s SuperBlock) Get_s_def_resgid() uint16 { return binary.LittleEndian.Uint16(s[82:84]) } +// Put_s_def_resgid sets s_def_resgid. +func (s SuperBlock) Put_s_def_resgid(v uint16) { + binary.LittleEndian.PutUint16(s[82:84], v) +} + // Get_s_first_ino returns s_first_ino. func (s SuperBlock) Get_s_first_ino() uint32 { return binary.LittleEndian.Uint32(s[84:88]) } +// Put_s_first_ino sets s_first_ino. +func (s SuperBlock) Put_s_first_ino(v uint32) { + binary.LittleEndian.PutUint32(s[84:88], v) +} + // Get_s_inode_size returns s_inode_size. func (s SuperBlock) Get_s_inode_size() uint16 { return binary.LittleEndian.Uint16(s[88:90]) } +// Put_s_inode_size sets s_inode_size. +func (s SuperBlock) Put_s_inode_size(v uint16) { + binary.LittleEndian.PutUint16(s[88:90], v) +} + // Get_s_block_group_nr returns s_block_group_nr. func (s SuperBlock) Get_s_block_group_nr() uint16 { return binary.LittleEndian.Uint16(s[90:92]) } +// Put_s_block_group_nr sets s_block_group_nr. +func (s SuperBlock) Put_s_block_group_nr(v uint16) { + binary.LittleEndian.PutUint16(s[90:92], v) +} + // Get_s_feature_compat returns s_feature_compat. func (s SuperBlock) Get_s_feature_compat() uint32 { return binary.LittleEndian.Uint32(s[92:96]) } +// Put_s_feature_compat sets s_feature_compat. +func (s SuperBlock) Put_s_feature_compat(v uint32) { + binary.LittleEndian.PutUint32(s[92:96], v) +} + // Get_s_feature_incompat returns s_feature_incompat. func (s SuperBlock) Get_s_feature_incompat() uint32 { return binary.LittleEndian.Uint32(s[96:100]) } +// Put_s_feature_incompat sets s_feature_incompat. +func (s SuperBlock) Put_s_feature_incompat(v uint32) { + binary.LittleEndian.PutUint32(s[96:100], v) +} + // Get_s_feature_ro_compat returns s_feature_ro_compat. func (s SuperBlock) Get_s_feature_ro_compat() uint32 { return binary.LittleEndian.Uint32(s[100:104]) } +// Put_s_feature_ro_compat sets s_feature_ro_compat. +func (s SuperBlock) Put_s_feature_ro_compat(v uint32) { + binary.LittleEndian.PutUint32(s[100:104], v) +} + // Get_s_uuid returns s_uuid. func (s SuperBlock) Get_s_uuid() []byte { return s[104:120] } +// Put_s_uuid sets s_uuid. +func (s SuperBlock) Put_s_uuid(v []byte) { + copy(s[104:120], v) +} + // Get_s_volume_name returns s_volume_name. func (s SuperBlock) Get_s_volume_name() []byte { return s[120:136] } +// Put_s_volume_name sets s_volume_name. +func (s SuperBlock) Put_s_volume_name(v []byte) { + copy(s[120:136], v) +} + // Get_s_last_mounted returns s_last_mounted. func (s SuperBlock) Get_s_last_mounted() []byte { return s[136:200] } +// Put_s_last_mounted sets s_last_mounted. +func (s SuperBlock) Put_s_last_mounted(v []byte) { + copy(s[136:200], v) +} + // Get_s_algorithm_usage_bitmap returns s_algorithm_usage_bitmap. func (s SuperBlock) Get_s_algorithm_usage_bitmap() uint32 { return binary.LittleEndian.Uint32(s[200:204]) } +// Put_s_algorithm_usage_bitmap sets s_algorithm_usage_bitmap. +func (s SuperBlock) Put_s_algorithm_usage_bitmap(v uint32) { + binary.LittleEndian.PutUint32(s[200:204], v) +} + // Get_s_prealloc_blocks returns s_prealloc_blocks. func (s SuperBlock) Get_s_prealloc_blocks() byte { return s[204] } +// Put_s_prealloc_blocks sets s_prealloc_blocks. +func (s SuperBlock) Put_s_prealloc_blocks(v byte) { + s[204] = v +} + // Get_s_prealloc_dir_blocks returns s_prealloc_dir_blocks. func (s SuperBlock) Get_s_prealloc_dir_blocks() byte { return s[205] } +// Put_s_prealloc_dir_blocks sets s_prealloc_dir_blocks. +func (s SuperBlock) Put_s_prealloc_dir_blocks(v byte) { + s[205] = v +} + // Get_s_reserved_gdt_blocks returns s_reserved_gdt_blocks. func (s SuperBlock) Get_s_reserved_gdt_blocks() uint16 { return binary.LittleEndian.Uint16(s[206:208]) } +// Put_s_reserved_gdt_blocks sets s_reserved_gdt_blocks. +func (s SuperBlock) Put_s_reserved_gdt_blocks(v uint16) { + binary.LittleEndian.PutUint16(s[206:208], v) +} + // Get_s_journal_uuid returns s_journal_uuid. func (s SuperBlock) Get_s_journal_uuid() []byte { return s[208:224] } +// Put_s_journal_uuid sets s_journal_uuid. +func (s SuperBlock) Put_s_journal_uuid(v []byte) { + copy(s[208:224], v) +} + // Get_s_journal_inum returns s_journal_inum. func (s SuperBlock) Get_s_journal_inum() uint32 { return binary.LittleEndian.Uint32(s[224:228]) } +// Put_s_journal_inum sets s_journal_inum. +func (s SuperBlock) Put_s_journal_inum(v uint32) { + binary.LittleEndian.PutUint32(s[224:228], v) +} + // Get_s_journal_dev returns s_journal_dev. func (s SuperBlock) Get_s_journal_dev() uint32 { return binary.LittleEndian.Uint32(s[228:232]) } +// Put_s_journal_dev sets s_journal_dev. +func (s SuperBlock) Put_s_journal_dev(v uint32) { + binary.LittleEndian.PutUint32(s[228:232], v) +} + // Get_s_last_orphan returns s_last_orphan. func (s SuperBlock) Get_s_last_orphan() uint32 { return binary.LittleEndian.Uint32(s[232:236]) } +// Put_s_last_orphan sets s_last_orphan. +func (s SuperBlock) Put_s_last_orphan(v uint32) { + binary.LittleEndian.PutUint32(s[232:236], v) +} + // Get_s_def_hash_version returns s_def_hash_version. func (s SuperBlock) Get_s_def_hash_version() byte { return s[252] } +// Put_s_def_hash_version sets s_def_hash_version. +func (s SuperBlock) Put_s_def_hash_version(v byte) { + s[252] = v +} + // Get_s_jnl_backup_type returns s_jnl_backup_type. func (s SuperBlock) Get_s_jnl_backup_type() byte { return s[253] } +// Put_s_jnl_backup_type sets s_jnl_backup_type. +func (s SuperBlock) Put_s_jnl_backup_type(v byte) { + s[253] = v +} + // Get_s_reserved_word_pad returns s_reserved_word_pad. func (s SuperBlock) Get_s_reserved_word_pad() uint16 { return binary.LittleEndian.Uint16(s[254:256]) } +// Put_s_reserved_word_pad sets s_reserved_word_pad. +func (s SuperBlock) Put_s_reserved_word_pad(v uint16) { + binary.LittleEndian.PutUint16(s[254:256], v) +} + // Get_s_default_mount_opts returns s_default_mount_opts. func (s SuperBlock) Get_s_default_mount_opts() uint32 { return binary.LittleEndian.Uint32(s[256:260]) } +// Put_s_default_mount_opts sets s_default_mount_opts. +func (s SuperBlock) Put_s_default_mount_opts(v uint32) { + binary.LittleEndian.PutUint32(s[256:260], v) +} + // Get_s_first_meta_bg returns s_first_meta_bg. func (s SuperBlock) Get_s_first_meta_bg() uint32 { return binary.LittleEndian.Uint32(s[260:264]) } +// Put_s_first_meta_bg sets s_first_meta_bg. +func (s SuperBlock) Put_s_first_meta_bg(v uint32) { + binary.LittleEndian.PutUint32(s[260:264], v) +} + // Get_s_mkfs_time returns s_mkfs_time. func (s SuperBlock) Get_s_mkfs_time() uint32 { return binary.LittleEndian.Uint32(s[264:268]) } +// Put_s_mkfs_time sets s_mkfs_time. +func (s SuperBlock) Put_s_mkfs_time(v uint32) { + binary.LittleEndian.PutUint32(s[264:268], v) +} + // Get_s_blocks_count_hi returns s_blocks_count_hi. func (s SuperBlock) Get_s_blocks_count_hi() uint32 { return binary.LittleEndian.Uint32(s[336:340]) } +// Put_s_blocks_count_hi sets s_blocks_count_hi. +func (s SuperBlock) Put_s_blocks_count_hi(v uint32) { + binary.LittleEndian.PutUint32(s[336:340], v) +} + // Get_s_r_blocks_count_hi returns s_r_blocks_count_hi. func (s SuperBlock) Get_s_r_blocks_count_hi() uint32 { return binary.LittleEndian.Uint32(s[340:344]) } +// Put_s_r_blocks_count_hi sets s_r_blocks_count_hi. +func (s SuperBlock) Put_s_r_blocks_count_hi(v uint32) { + binary.LittleEndian.PutUint32(s[340:344], v) +} + // Get_s_free_blocks_hi returns s_free_blocks_hi. func (s SuperBlock) Get_s_free_blocks_hi() uint32 { return binary.LittleEndian.Uint32(s[344:348]) } +// Put_s_free_blocks_hi sets s_free_blocks_hi. +func (s SuperBlock) Put_s_free_blocks_hi(v uint32) { + binary.LittleEndian.PutUint32(s[344:348], v) +} + // Get_s_min_extra_isize returns s_min_extra_isize. func (s SuperBlock) Get_s_min_extra_isize() uint16 { return binary.LittleEndian.Uint16(s[348:350]) } +// Put_s_min_extra_isize sets s_min_extra_isize. +func (s SuperBlock) Put_s_min_extra_isize(v uint16) { + binary.LittleEndian.PutUint16(s[348:350], v) +} + // Get_s_want_extra_isize returns s_want_extra_isize. func (s SuperBlock) Get_s_want_extra_isize() uint16 { return binary.LittleEndian.Uint16(s[350:352]) } +// Put_s_want_extra_isize sets s_want_extra_isize. +func (s SuperBlock) Put_s_want_extra_isize(v uint16) { + binary.LittleEndian.PutUint16(s[350:352], v) +} + // Get_s_flags returns s_flags. func (s SuperBlock) Get_s_flags() uint32 { return binary.LittleEndian.Uint32(s[352:356]) } +// Put_s_flags sets s_flags. +func (s SuperBlock) Put_s_flags(v uint32) { + binary.LittleEndian.PutUint32(s[352:356], v) +} + // Get_s_raid_stride returns s_raid_stride. func (s SuperBlock) Get_s_raid_stride() uint16 { return binary.LittleEndian.Uint16(s[356:358]) } +// Put_s_raid_stride sets s_raid_stride. +func (s SuperBlock) Put_s_raid_stride(v uint16) { + binary.LittleEndian.PutUint16(s[356:358], v) +} + // Get_s_mmp_interval returns s_mmp_interval. func (s SuperBlock) Get_s_mmp_interval() uint16 { return binary.LittleEndian.Uint16(s[358:360]) } +// Put_s_mmp_interval sets s_mmp_interval. +func (s SuperBlock) Put_s_mmp_interval(v uint16) { + binary.LittleEndian.PutUint16(s[358:360], v) +} + // Get_s_mmp_block returns s_mmp_block. func (s SuperBlock) Get_s_mmp_block() uint64 { return binary.LittleEndian.Uint64(s[360:368]) } +// Put_s_mmp_block sets s_mmp_block. +func (s SuperBlock) Put_s_mmp_block(v uint64) { + binary.LittleEndian.PutUint64(s[360:368], v) +} + // Get_s_raid_stripe_width returns s_raid_stripe_width. func (s SuperBlock) Get_s_raid_stripe_width() uint32 { return binary.LittleEndian.Uint32(s[368:372]) } +// Put_s_raid_stripe_width sets s_raid_stripe_width. +func (s SuperBlock) Put_s_raid_stripe_width(v uint32) { + binary.LittleEndian.PutUint32(s[368:372], v) +} + // Get_s_checksum returns s_checksum. func (s SuperBlock) Get_s_checksum() uint32 { return binary.LittleEndian.Uint32(s[1020:1024]) } +// Put_s_checksum sets s_checksum. +func (s SuperBlock) Put_s_checksum(v uint32) { + binary.LittleEndian.PutUint32(s[1020:1024], v) +} + // SUPERBLOCK_SIZE is the size of the SuperBlock struct. const SUPERBLOCK_SIZE = 1024 diff --git a/blkid/internal/filesystems/iso9660/volumedescriptor.go b/blkid/internal/filesystems/iso9660/volumedescriptor.go index 78120d0..c1ec7a4 100644 --- a/blkid/internal/filesystems/iso9660/volumedescriptor.go +++ b/blkid/internal/filesystems/iso9660/volumedescriptor.go @@ -18,150 +18,300 @@ func (s VolumeDescriptor) Get_vd_type() byte { return s[0] } +// Put_vd_type sets vd_type. +func (s VolumeDescriptor) Put_vd_type(v byte) { + s[0] = v +} + // Get_vd_id returns vd_id. func (s VolumeDescriptor) Get_vd_id() []byte { return s[1:6] } +// Put_vd_id sets vd_id. +func (s VolumeDescriptor) Put_vd_id(v []byte) { + copy(s[1:6], v) +} + // Get_vd_version returns vd_version. func (s VolumeDescriptor) Get_vd_version() byte { return s[6] } +// Put_vd_version sets vd_version. +func (s VolumeDescriptor) Put_vd_version(v byte) { + s[6] = v +} + // Get_flags returns flags. func (s VolumeDescriptor) Get_flags() byte { return s[7] } +// Put_flags sets flags. +func (s VolumeDescriptor) Put_flags(v byte) { + s[7] = v +} + // Get_system_id returns system_id. func (s VolumeDescriptor) Get_system_id() []byte { return s[8:40] } +// Put_system_id sets system_id. +func (s VolumeDescriptor) Put_system_id(v []byte) { + copy(s[8:40], v) +} + // Get_volume_id returns volume_id. func (s VolumeDescriptor) Get_volume_id() []byte { return s[40:72] } +// Put_volume_id sets volume_id. +func (s VolumeDescriptor) Put_volume_id(v []byte) { + copy(s[40:72], v) +} + // Get_unused returns unused. func (s VolumeDescriptor) Get_unused() []byte { return s[72:80] } +// Put_unused sets unused. +func (s VolumeDescriptor) Put_unused(v []byte) { + copy(s[72:80], v) +} + // Get_space_size returns space_size. func (s VolumeDescriptor) Get_space_size() []byte { return s[80:88] } +// Put_space_size sets space_size. +func (s VolumeDescriptor) Put_space_size(v []byte) { + copy(s[80:88], v) +} + // Get_escape_sequences returns escape_sequences. func (s VolumeDescriptor) Get_escape_sequences() []byte { return s[88:120] } +// Put_escape_sequences sets escape_sequences. +func (s VolumeDescriptor) Put_escape_sequences(v []byte) { + copy(s[88:120], v) +} + // Get_set_size returns set_size. func (s VolumeDescriptor) Get_set_size() []byte { return s[120:124] } +// Put_set_size sets set_size. +func (s VolumeDescriptor) Put_set_size(v []byte) { + copy(s[120:124], v) +} + // Get_vol_seq_num returns vol_seq_num. func (s VolumeDescriptor) Get_vol_seq_num() []byte { return s[124:128] } +// Put_vol_seq_num sets vol_seq_num. +func (s VolumeDescriptor) Put_vol_seq_num(v []byte) { + copy(s[124:128], v) +} + // Get_logical_block_size returns logical_block_size. func (s VolumeDescriptor) Get_logical_block_size() []byte { return s[128:132] } +// Put_logical_block_size sets logical_block_size. +func (s VolumeDescriptor) Put_logical_block_size(v []byte) { + copy(s[128:132], v) +} + // Get_path_table_size returns path_table_size. func (s VolumeDescriptor) Get_path_table_size() []byte { return s[132:140] } +// Put_path_table_size sets path_table_size. +func (s VolumeDescriptor) Put_path_table_size(v []byte) { + copy(s[132:140], v) +} + // Get_type_l_path_table returns type_l_path_table. func (s VolumeDescriptor) Get_type_l_path_table() []byte { return s[140:144] } +// Put_type_l_path_table sets type_l_path_table. +func (s VolumeDescriptor) Put_type_l_path_table(v []byte) { + copy(s[140:144], v) +} + // Get_opt_type_l_path_table returns opt_type_l_path_table. func (s VolumeDescriptor) Get_opt_type_l_path_table() []byte { return s[144:148] } +// Put_opt_type_l_path_table sets opt_type_l_path_table. +func (s VolumeDescriptor) Put_opt_type_l_path_table(v []byte) { + copy(s[144:148], v) +} + // Get_type_m_path_table returns type_m_path_table. func (s VolumeDescriptor) Get_type_m_path_table() []byte { return s[148:152] } +// Put_type_m_path_table sets type_m_path_table. +func (s VolumeDescriptor) Put_type_m_path_table(v []byte) { + copy(s[148:152], v) +} + // Get_opt_type_m_path_table returns opt_type_m_path_table. func (s VolumeDescriptor) Get_opt_type_m_path_table() []byte { return s[152:156] } +// Put_opt_type_m_path_table sets opt_type_m_path_table. +func (s VolumeDescriptor) Put_opt_type_m_path_table(v []byte) { + copy(s[152:156], v) +} + // Get_root_dir_record returns root_dir_record. func (s VolumeDescriptor) Get_root_dir_record() []byte { return s[156:190] } +// Put_root_dir_record sets root_dir_record. +func (s VolumeDescriptor) Put_root_dir_record(v []byte) { + copy(s[156:190], v) +} + // Get_volume_set_id returns volume_set_id. func (s VolumeDescriptor) Get_volume_set_id() []byte { return s[190:318] } +// Put_volume_set_id sets volume_set_id. +func (s VolumeDescriptor) Put_volume_set_id(v []byte) { + copy(s[190:318], v) +} + // Get_publisher_id returns publisher_id. func (s VolumeDescriptor) Get_publisher_id() []byte { return s[318:446] } +// Put_publisher_id sets publisher_id. +func (s VolumeDescriptor) Put_publisher_id(v []byte) { + copy(s[318:446], v) +} + // Get_data_preparer_id returns data_preparer_id. func (s VolumeDescriptor) Get_data_preparer_id() []byte { return s[446:574] } +// Put_data_preparer_id sets data_preparer_id. +func (s VolumeDescriptor) Put_data_preparer_id(v []byte) { + copy(s[446:574], v) +} + // Get_application_id returns application_id. func (s VolumeDescriptor) Get_application_id() []byte { return s[574:702] } +// Put_application_id sets application_id. +func (s VolumeDescriptor) Put_application_id(v []byte) { + copy(s[574:702], v) +} + // Get_copyright_file_id returns copyright_file_id. func (s VolumeDescriptor) Get_copyright_file_id() []byte { return s[702:739] } +// Put_copyright_file_id sets copyright_file_id. +func (s VolumeDescriptor) Put_copyright_file_id(v []byte) { + copy(s[702:739], v) +} + // Get_abstract_file_id returns abstract_file_id. func (s VolumeDescriptor) Get_abstract_file_id() []byte { return s[739:776] } +// Put_abstract_file_id sets abstract_file_id. +func (s VolumeDescriptor) Put_abstract_file_id(v []byte) { + copy(s[739:776], v) +} + // Get_bibliographic_file_id returns bibliographic_file_id. func (s VolumeDescriptor) Get_bibliographic_file_id() []byte { return s[776:813] } +// Put_bibliographic_file_id sets bibliographic_file_id. +func (s VolumeDescriptor) Put_bibliographic_file_id(v []byte) { + copy(s[776:813], v) +} + // Get_created returns created. func (s VolumeDescriptor) Get_created() []byte { return s[813:830] } +// Put_created sets created. +func (s VolumeDescriptor) Put_created(v []byte) { + copy(s[813:830], v) +} + // Get_modified returns modified. func (s VolumeDescriptor) Get_modified() []byte { return s[830:847] } +// Put_modified sets modified. +func (s VolumeDescriptor) Put_modified(v []byte) { + copy(s[830:847], v) +} + // Get_expiration returns expiration. func (s VolumeDescriptor) Get_expiration() []byte { return s[847:864] } +// Put_expiration sets expiration. +func (s VolumeDescriptor) Put_expiration(v []byte) { + copy(s[847:864], v) +} + // Get_effective returns effective. func (s VolumeDescriptor) Get_effective() []byte { return s[864:881] } +// Put_effective sets effective. +func (s VolumeDescriptor) Put_effective(v []byte) { + copy(s[864:881], v) +} + // Get_std_version returns std_version. func (s VolumeDescriptor) Get_std_version() byte { return s[881] } +// Put_std_version sets std_version. +func (s VolumeDescriptor) Put_std_version(v byte) { + s[881] = v +} + // VOLUMEDESCRIPTOR_SIZE is the size of the VolumeDescriptor struct. const VOLUMEDESCRIPTOR_SIZE = 882 diff --git a/blkid/internal/filesystems/luks/luks2header.go b/blkid/internal/filesystems/luks/luks2header.go index b9bd400..ae3ec10 100644 --- a/blkid/internal/filesystems/luks/luks2header.go +++ b/blkid/internal/filesystems/luks/luks2header.go @@ -18,60 +18,120 @@ func (s Luks2Header) Get_magic() []byte { return s[0:6] } +// Put_magic sets magic. +func (s Luks2Header) Put_magic(v []byte) { + copy(s[0:6], v) +} + // Get_version returns version. func (s Luks2Header) Get_version() uint16 { return binary.BigEndian.Uint16(s[6:8]) } +// Put_version sets version. +func (s Luks2Header) Put_version(v uint16) { + binary.BigEndian.PutUint16(s[6:8], v) +} + // Get_hdr_size returns in bytes, including JSON area. func (s Luks2Header) Get_hdr_size() uint64 { return binary.BigEndian.Uint64(s[8:16]) } +// Put_hdr_size sets in bytes, including JSON area. +func (s Luks2Header) Put_hdr_size(v uint64) { + binary.BigEndian.PutUint64(s[8:16], v) +} + // Get_seqid returns increased on every update. func (s Luks2Header) Get_seqid() uint64 { return binary.BigEndian.Uint64(s[16:24]) } +// Put_seqid sets increased on every update. +func (s Luks2Header) Put_seqid(v uint64) { + binary.BigEndian.PutUint64(s[16:24], v) +} + // Get_label returns label. func (s Luks2Header) Get_label() []byte { return s[24:72] } +// Put_label sets label. +func (s Luks2Header) Put_label(v []byte) { + copy(s[24:72], v) +} + // Get_checksum_alg returns checksum_alg. func (s Luks2Header) Get_checksum_alg() []byte { return s[72:104] } +// Put_checksum_alg sets checksum_alg. +func (s Luks2Header) Put_checksum_alg(v []byte) { + copy(s[72:104], v) +} + // Get_salt returns unique for every header/offset. func (s Luks2Header) Get_salt() []byte { return s[104:168] } +// Put_salt sets unique for every header/offset. +func (s Luks2Header) Put_salt(v []byte) { + copy(s[104:168], v) +} + // Get_uuid returns uuid. func (s Luks2Header) Get_uuid() []byte { return s[168:208] } +// Put_uuid sets uuid. +func (s Luks2Header) Put_uuid(v []byte) { + copy(s[168:208], v) +} + // Get_subsystem returns owner subsystem label. func (s Luks2Header) Get_subsystem() []byte { return s[208:256] } +// Put_subsystem sets owner subsystem label. +func (s Luks2Header) Put_subsystem(v []byte) { + copy(s[208:256], v) +} + // Get_hdr_offset returns offset from device start in bytes. func (s Luks2Header) Get_hdr_offset() uint64 { return binary.BigEndian.Uint64(s[256:264]) } +// Put_hdr_offset sets offset from device start in bytes. +func (s Luks2Header) Put_hdr_offset(v uint64) { + binary.BigEndian.PutUint64(s[256:264], v) +} + // Get__padding returns _padding. func (s Luks2Header) Get__padding() []byte { return s[264:448] } +// Put__padding sets _padding. +func (s Luks2Header) Put__padding(v []byte) { + copy(s[264:448], v) +} + // Get_csum returns csum. func (s Luks2Header) Get_csum() []byte { return s[448:512] } +// Put_csum sets csum. +func (s Luks2Header) Put_csum(v []byte) { + copy(s[448:512], v) +} + // LUKS2HEADER_SIZE is the size of the Luks2Header struct. const LUKS2HEADER_SIZE = 512 diff --git a/blkid/internal/filesystems/lvm2/lvm2header.go b/blkid/internal/filesystems/lvm2/lvm2header.go index 6196bbd..a788620 100644 --- a/blkid/internal/filesystems/lvm2/lvm2header.go +++ b/blkid/internal/filesystems/lvm2/lvm2header.go @@ -18,30 +18,60 @@ func (s LVM2Header) Get_id() []byte { return s[0:8] } +// Put_id sets LABELONE. +func (s LVM2Header) Put_id(v []byte) { + copy(s[0:8], v) +} + // Get_sector_xl returns Sector number of this label. func (s LVM2Header) Get_sector_xl() uint64 { return binary.LittleEndian.Uint64(s[8:16]) } +// Put_sector_xl sets Sector number of this label. +func (s LVM2Header) Put_sector_xl(v uint64) { + binary.LittleEndian.PutUint64(s[8:16], v) +} + // Get_crc_xl returns From next field to end of sector. func (s LVM2Header) Get_crc_xl() uint32 { return binary.LittleEndian.Uint32(s[16:20]) } +// Put_crc_xl sets From next field to end of sector. +func (s LVM2Header) Put_crc_xl(v uint32) { + binary.LittleEndian.PutUint32(s[16:20], v) +} + // Get_offset_xl returns Offset from start of struct to contents. func (s LVM2Header) Get_offset_xl() uint32 { return binary.LittleEndian.Uint32(s[20:24]) } +// Put_offset_xl sets Offset from start of struct to contents. +func (s LVM2Header) Put_offset_xl(v uint32) { + binary.LittleEndian.PutUint32(s[20:24], v) +} + // Get_type returns LVM2 001. func (s LVM2Header) Get_type() []byte { return s[24:32] } +// Put_type sets LVM2 001. +func (s LVM2Header) Put_type(v []byte) { + copy(s[24:32], v) +} + // Get_pv_uuid returns pv_uuid. func (s LVM2Header) Get_pv_uuid() []byte { return s[32:64] } +// Put_pv_uuid sets pv_uuid. +func (s LVM2Header) Put_pv_uuid(v []byte) { + copy(s[32:64], v) +} + // LVM2HEADER_SIZE is the size of the LVM2Header struct. const LVM2HEADER_SIZE = 64 diff --git a/blkid/internal/filesystems/squashfs/superblock.go b/blkid/internal/filesystems/squashfs/superblock.go index 151c197..941a4e4 100644 --- a/blkid/internal/filesystems/squashfs/superblock.go +++ b/blkid/internal/filesystems/squashfs/superblock.go @@ -18,95 +18,190 @@ func (s SuperBlock) Get_magic() uint32 { return binary.LittleEndian.Uint32(s[0:4]) } +// Put_magic sets magic. +func (s SuperBlock) Put_magic(v uint32) { + binary.LittleEndian.PutUint32(s[0:4], v) +} + // Get_inode_count returns inode_count. func (s SuperBlock) Get_inode_count() uint32 { return binary.LittleEndian.Uint32(s[4:8]) } +// Put_inode_count sets inode_count. +func (s SuperBlock) Put_inode_count(v uint32) { + binary.LittleEndian.PutUint32(s[4:8], v) +} + // Get_mod_time returns mod_time. func (s SuperBlock) Get_mod_time() uint32 { return binary.LittleEndian.Uint32(s[8:12]) } +// Put_mod_time sets mod_time. +func (s SuperBlock) Put_mod_time(v uint32) { + binary.LittleEndian.PutUint32(s[8:12], v) +} + // Get_block_size returns block_size. func (s SuperBlock) Get_block_size() uint32 { return binary.LittleEndian.Uint32(s[12:16]) } +// Put_block_size sets block_size. +func (s SuperBlock) Put_block_size(v uint32) { + binary.LittleEndian.PutUint32(s[12:16], v) +} + // Get_frag_count returns frag_count. func (s SuperBlock) Get_frag_count() uint32 { return binary.LittleEndian.Uint32(s[16:20]) } +// Put_frag_count sets frag_count. +func (s SuperBlock) Put_frag_count(v uint32) { + binary.LittleEndian.PutUint32(s[16:20], v) +} + // Get_compressor returns compressor. func (s SuperBlock) Get_compressor() uint16 { return binary.LittleEndian.Uint16(s[20:22]) } +// Put_compressor sets compressor. +func (s SuperBlock) Put_compressor(v uint16) { + binary.LittleEndian.PutUint16(s[20:22], v) +} + // Get_block_log returns block_log. func (s SuperBlock) Get_block_log() uint16 { return binary.LittleEndian.Uint16(s[22:24]) } +// Put_block_log sets block_log. +func (s SuperBlock) Put_block_log(v uint16) { + binary.LittleEndian.PutUint16(s[22:24], v) +} + // Get_flags returns flags. func (s SuperBlock) Get_flags() uint16 { return binary.LittleEndian.Uint16(s[24:26]) } +// Put_flags sets flags. +func (s SuperBlock) Put_flags(v uint16) { + binary.LittleEndian.PutUint16(s[24:26], v) +} + // Get_id_count returns id_count. func (s SuperBlock) Get_id_count() uint16 { return binary.LittleEndian.Uint16(s[26:28]) } +// Put_id_count sets id_count. +func (s SuperBlock) Put_id_count(v uint16) { + binary.LittleEndian.PutUint16(s[26:28], v) +} + // Get_version_major returns version_major. func (s SuperBlock) Get_version_major() uint16 { return binary.LittleEndian.Uint16(s[28:30]) } +// Put_version_major sets version_major. +func (s SuperBlock) Put_version_major(v uint16) { + binary.LittleEndian.PutUint16(s[28:30], v) +} + // Get_version_minor returns version_minor. func (s SuperBlock) Get_version_minor() uint16 { return binary.LittleEndian.Uint16(s[30:32]) } +// Put_version_minor sets version_minor. +func (s SuperBlock) Put_version_minor(v uint16) { + binary.LittleEndian.PutUint16(s[30:32], v) +} + // Get_root_inode returns root_inode. func (s SuperBlock) Get_root_inode() uint64 { return binary.LittleEndian.Uint64(s[32:40]) } +// Put_root_inode sets root_inode. +func (s SuperBlock) Put_root_inode(v uint64) { + binary.LittleEndian.PutUint64(s[32:40], v) +} + // Get_bytes_used returns bytes_used. func (s SuperBlock) Get_bytes_used() uint64 { return binary.LittleEndian.Uint64(s[40:48]) } +// Put_bytes_used sets bytes_used. +func (s SuperBlock) Put_bytes_used(v uint64) { + binary.LittleEndian.PutUint64(s[40:48], v) +} + // Get_id_table returns id_table. func (s SuperBlock) Get_id_table() uint64 { return binary.LittleEndian.Uint64(s[48:56]) } +// Put_id_table sets id_table. +func (s SuperBlock) Put_id_table(v uint64) { + binary.LittleEndian.PutUint64(s[48:56], v) +} + // Get_xattr_table returns xattr_table. func (s SuperBlock) Get_xattr_table() uint64 { return binary.LittleEndian.Uint64(s[56:64]) } +// Put_xattr_table sets xattr_table. +func (s SuperBlock) Put_xattr_table(v uint64) { + binary.LittleEndian.PutUint64(s[56:64], v) +} + // Get_inode_table returns inode_table. func (s SuperBlock) Get_inode_table() uint64 { return binary.LittleEndian.Uint64(s[64:72]) } +// Put_inode_table sets inode_table. +func (s SuperBlock) Put_inode_table(v uint64) { + binary.LittleEndian.PutUint64(s[64:72], v) +} + // Get_dir_table returns dir_table. func (s SuperBlock) Get_dir_table() uint64 { return binary.LittleEndian.Uint64(s[72:80]) } +// Put_dir_table sets dir_table. +func (s SuperBlock) Put_dir_table(v uint64) { + binary.LittleEndian.PutUint64(s[72:80], v) +} + // Get_frag_table returns frag_table. func (s SuperBlock) Get_frag_table() uint64 { return binary.LittleEndian.Uint64(s[80:88]) } +// Put_frag_table sets frag_table. +func (s SuperBlock) Put_frag_table(v uint64) { + binary.LittleEndian.PutUint64(s[80:88], v) +} + // Get_export_table returns export_table. func (s SuperBlock) Get_export_table() uint64 { return binary.LittleEndian.Uint64(s[88:96]) } +// Put_export_table sets export_table. +func (s SuperBlock) Put_export_table(v uint64) { + binary.LittleEndian.PutUint64(s[88:96], v) +} + // SUPERBLOCK_SIZE is the size of the SuperBlock struct. const SUPERBLOCK_SIZE = 96 diff --git a/blkid/internal/filesystems/swap/swapheader.go b/blkid/internal/filesystems/swap/swapheader.go index 7b22935..b68bf3c 100644 --- a/blkid/internal/filesystems/swap/swapheader.go +++ b/blkid/internal/filesystems/swap/swapheader.go @@ -18,25 +18,50 @@ func (s SwapHeader) Get_version() uint32 { return binary.LittleEndian.Uint32(s[0:4]) } +// Put_version sets version. +func (s SwapHeader) Put_version(v uint32) { + binary.LittleEndian.PutUint32(s[0:4], v) +} + // Get_lastpage returns lastpage. func (s SwapHeader) Get_lastpage() uint32 { return binary.LittleEndian.Uint32(s[4:8]) } +// Put_lastpage sets lastpage. +func (s SwapHeader) Put_lastpage(v uint32) { + binary.LittleEndian.PutUint32(s[4:8], v) +} + // Get_nr_badpages returns nr_badpages. func (s SwapHeader) Get_nr_badpages() uint32 { return binary.LittleEndian.Uint32(s[8:12]) } +// Put_nr_badpages sets nr_badpages. +func (s SwapHeader) Put_nr_badpages(v uint32) { + binary.LittleEndian.PutUint32(s[8:12], v) +} + // Get_uuid returns uuid. func (s SwapHeader) Get_uuid() []byte { return s[12:28] } +// Put_uuid sets uuid. +func (s SwapHeader) Put_uuid(v []byte) { + copy(s[12:28], v) +} + // Get_volume returns volume. func (s SwapHeader) Get_volume() []byte { return s[28:44] } +// Put_volume sets volume. +func (s SwapHeader) Put_volume(v []byte) { + copy(s[28:44], v) +} + // SWAPHEADER_SIZE is the size of the SwapHeader struct. const SWAPHEADER_SIZE = 516 diff --git a/blkid/internal/filesystems/vfat/msdossb.go b/blkid/internal/filesystems/vfat/msdossb.go index 2b440dc..a7c8f28 100644 --- a/blkid/internal/filesystems/vfat/msdossb.go +++ b/blkid/internal/filesystems/vfat/msdossb.go @@ -18,110 +18,220 @@ func (s MSDOSSB) Get_ms_ignored() []byte { return s[0:3] } +// Put_ms_ignored sets ms_ignored. +func (s MSDOSSB) Put_ms_ignored(v []byte) { + copy(s[0:3], v) +} + // Get_ms_sysid returns ms_sysid. func (s MSDOSSB) Get_ms_sysid() []byte { return s[3:11] } +// Put_ms_sysid sets ms_sysid. +func (s MSDOSSB) Put_ms_sysid(v []byte) { + copy(s[3:11], v) +} + // Get_ms_sector_size returns ms_sector_size. func (s MSDOSSB) Get_ms_sector_size() uint16 { return binary.LittleEndian.Uint16(s[11:13]) } +// Put_ms_sector_size sets ms_sector_size. +func (s MSDOSSB) Put_ms_sector_size(v uint16) { + binary.LittleEndian.PutUint16(s[11:13], v) +} + // Get_ms_cluster_size returns ms_cluster_size. func (s MSDOSSB) Get_ms_cluster_size() byte { return s[13] } +// Put_ms_cluster_size sets ms_cluster_size. +func (s MSDOSSB) Put_ms_cluster_size(v byte) { + s[13] = v +} + // Get_ms_reserved returns ms_reserved. func (s MSDOSSB) Get_ms_reserved() uint16 { return binary.LittleEndian.Uint16(s[14:16]) } +// Put_ms_reserved sets ms_reserved. +func (s MSDOSSB) Put_ms_reserved(v uint16) { + binary.LittleEndian.PutUint16(s[14:16], v) +} + // Get_ms_fats returns ms_fats. func (s MSDOSSB) Get_ms_fats() byte { return s[16] } +// Put_ms_fats sets ms_fats. +func (s MSDOSSB) Put_ms_fats(v byte) { + s[16] = v +} + // Get_ms_dir_entries returns ms_dir_entries. func (s MSDOSSB) Get_ms_dir_entries() uint16 { return binary.LittleEndian.Uint16(s[17:19]) } +// Put_ms_dir_entries sets ms_dir_entries. +func (s MSDOSSB) Put_ms_dir_entries(v uint16) { + binary.LittleEndian.PutUint16(s[17:19], v) +} + // Get_ms_sectors returns =0 iff V3 or later. func (s MSDOSSB) Get_ms_sectors() uint16 { return binary.LittleEndian.Uint16(s[19:21]) } +// Put_ms_sectors sets =0 iff V3 or later. +func (s MSDOSSB) Put_ms_sectors(v uint16) { + binary.LittleEndian.PutUint16(s[19:21], v) +} + // Get_ms_media returns ms_media. func (s MSDOSSB) Get_ms_media() byte { return s[21] } +// Put_ms_media sets ms_media. +func (s MSDOSSB) Put_ms_media(v byte) { + s[21] = v +} + // Get_ms_fat_length returns Sectors per FAT. func (s MSDOSSB) Get_ms_fat_length() uint16 { return binary.LittleEndian.Uint16(s[22:24]) } +// Put_ms_fat_length sets Sectors per FAT. +func (s MSDOSSB) Put_ms_fat_length(v uint16) { + binary.LittleEndian.PutUint16(s[22:24], v) +} + // Get_ms_secs_track returns ms_secs_track. func (s MSDOSSB) Get_ms_secs_track() uint16 { return binary.LittleEndian.Uint16(s[24:26]) } +// Put_ms_secs_track sets ms_secs_track. +func (s MSDOSSB) Put_ms_secs_track(v uint16) { + binary.LittleEndian.PutUint16(s[24:26], v) +} + // Get_ms_heads returns ms_heads. func (s MSDOSSB) Get_ms_heads() uint16 { return binary.LittleEndian.Uint16(s[26:28]) } +// Put_ms_heads sets ms_heads. +func (s MSDOSSB) Put_ms_heads(v uint16) { + binary.LittleEndian.PutUint16(s[26:28], v) +} + // Get_ms_hidden returns ms_hidden. func (s MSDOSSB) Get_ms_hidden() uint32 { return binary.LittleEndian.Uint32(s[28:32]) } +// Put_ms_hidden sets ms_hidden. +func (s MSDOSSB) Put_ms_hidden(v uint32) { + binary.LittleEndian.PutUint32(s[28:32], v) +} + // Get_ms_total_sect returns iff ms_sectors == 0. func (s MSDOSSB) Get_ms_total_sect() uint32 { return binary.LittleEndian.Uint32(s[32:36]) } +// Put_ms_total_sect sets iff ms_sectors == 0. +func (s MSDOSSB) Put_ms_total_sect(v uint32) { + binary.LittleEndian.PutUint32(s[32:36], v) +} + // Get_ms_drive_number returns ms_drive_number. func (s MSDOSSB) Get_ms_drive_number() byte { return s[36] } +// Put_ms_drive_number sets ms_drive_number. +func (s MSDOSSB) Put_ms_drive_number(v byte) { + s[36] = v +} + // Get_ms_boot_flags returns ms_boot_flags. func (s MSDOSSB) Get_ms_boot_flags() byte { return s[37] } +// Put_ms_boot_flags sets ms_boot_flags. +func (s MSDOSSB) Put_ms_boot_flags(v byte) { + s[37] = v +} + // Get_ms_ext_boot_sign returns 0x28 - DOS 3.4 EBPB; 0x29 - DOS 4.0 EBPB. func (s MSDOSSB) Get_ms_ext_boot_sign() byte { return s[38] } +// Put_ms_ext_boot_sign sets 0x28 - DOS 3.4 EBPB; 0x29 - DOS 4.0 EBPB. +func (s MSDOSSB) Put_ms_ext_boot_sign(v byte) { + s[38] = v +} + // Get_ms_serno returns ms_serno. func (s MSDOSSB) Get_ms_serno() []byte { return s[39:43] } +// Put_ms_serno sets ms_serno. +func (s MSDOSSB) Put_ms_serno(v []byte) { + copy(s[39:43], v) +} + // Get_ms_label returns ms_label. func (s MSDOSSB) Get_ms_label() []byte { return s[43:54] } +// Put_ms_label sets ms_label. +func (s MSDOSSB) Put_ms_label(v []byte) { + copy(s[43:54], v) +} + // Get_ms_magic returns ms_magic. func (s MSDOSSB) Get_ms_magic() []byte { return s[54:62] } +// Put_ms_magic sets ms_magic. +func (s MSDOSSB) Put_ms_magic(v []byte) { + copy(s[54:62], v) +} + // Get_ms_dummy2 returns ms_dummy2. func (s MSDOSSB) Get_ms_dummy2() []byte { return s[62:510] } +// Put_ms_dummy2 sets ms_dummy2. +func (s MSDOSSB) Put_ms_dummy2(v []byte) { + copy(s[62:510], v) +} + // Get_ms_pmagic returns ms_pmagic. func (s MSDOSSB) Get_ms_pmagic() []byte { return s[510:512] } +// Put_ms_pmagic sets ms_pmagic. +func (s MSDOSSB) Put_ms_pmagic(v []byte) { + copy(s[510:512], v) +} + // MSDOSSB_SIZE is the size of the MSDOSSB struct. const MSDOSSB_SIZE = 512 diff --git a/blkid/internal/filesystems/vfat/vfatsb.go b/blkid/internal/filesystems/vfat/vfatsb.go index 4f5f55a..47649fa 100644 --- a/blkid/internal/filesystems/vfat/vfatsb.go +++ b/blkid/internal/filesystems/vfat/vfatsb.go @@ -18,140 +18,280 @@ func (s VFATSB) Get_vs_ignored() []byte { return s[0:3] } +// Put_vs_ignored sets vs_ignored. +func (s VFATSB) Put_vs_ignored(v []byte) { + copy(s[0:3], v) +} + // Get_vs_sysid returns vs_sysid. func (s VFATSB) Get_vs_sysid() []byte { return s[3:11] } +// Put_vs_sysid sets vs_sysid. +func (s VFATSB) Put_vs_sysid(v []byte) { + copy(s[3:11], v) +} + // Get_vs_sector_size returns vs_sector_size. func (s VFATSB) Get_vs_sector_size() []byte { return s[11:13] } +// Put_vs_sector_size sets vs_sector_size. +func (s VFATSB) Put_vs_sector_size(v []byte) { + copy(s[11:13], v) +} + // Get_vs_cluster_size returns vs_cluster_size. func (s VFATSB) Get_vs_cluster_size() byte { return s[13] } +// Put_vs_cluster_size sets vs_cluster_size. +func (s VFATSB) Put_vs_cluster_size(v byte) { + s[13] = v +} + // Get_vs_reserved returns vs_reserved. func (s VFATSB) Get_vs_reserved() uint16 { return binary.LittleEndian.Uint16(s[14:16]) } +// Put_vs_reserved sets vs_reserved. +func (s VFATSB) Put_vs_reserved(v uint16) { + binary.LittleEndian.PutUint16(s[14:16], v) +} + // Get_vs_fats returns vs_fats. func (s VFATSB) Get_vs_fats() byte { return s[16] } +// Put_vs_fats sets vs_fats. +func (s VFATSB) Put_vs_fats(v byte) { + s[16] = v +} + // Get_vs_dir_entries returns vs_dir_entries. func (s VFATSB) Get_vs_dir_entries() []byte { return s[17:19] } +// Put_vs_dir_entries sets vs_dir_entries. +func (s VFATSB) Put_vs_dir_entries(v []byte) { + copy(s[17:19], v) +} + // Get_vs_sectors returns vs_sectors. func (s VFATSB) Get_vs_sectors() []byte { return s[19:21] } +// Put_vs_sectors sets vs_sectors. +func (s VFATSB) Put_vs_sectors(v []byte) { + copy(s[19:21], v) +} + // Get_vs_media returns vs_media. func (s VFATSB) Get_vs_media() byte { return s[21] } +// Put_vs_media sets vs_media. +func (s VFATSB) Put_vs_media(v byte) { + s[21] = v +} + // Get_vs_fat_length returns vs_fat_length. func (s VFATSB) Get_vs_fat_length() uint16 { return binary.LittleEndian.Uint16(s[22:24]) } +// Put_vs_fat_length sets vs_fat_length. +func (s VFATSB) Put_vs_fat_length(v uint16) { + binary.LittleEndian.PutUint16(s[22:24], v) +} + // Get_vs_secs_track returns vs_secs_track. func (s VFATSB) Get_vs_secs_track() uint16 { return binary.LittleEndian.Uint16(s[24:26]) } +// Put_vs_secs_track sets vs_secs_track. +func (s VFATSB) Put_vs_secs_track(v uint16) { + binary.LittleEndian.PutUint16(s[24:26], v) +} + // Get_vs_heads returns vs_heads. func (s VFATSB) Get_vs_heads() uint16 { return binary.LittleEndian.Uint16(s[26:28]) } +// Put_vs_heads sets vs_heads. +func (s VFATSB) Put_vs_heads(v uint16) { + binary.LittleEndian.PutUint16(s[26:28], v) +} + // Get_vs_hidden returns vs_hidden. func (s VFATSB) Get_vs_hidden() uint32 { return binary.LittleEndian.Uint32(s[28:32]) } +// Put_vs_hidden sets vs_hidden. +func (s VFATSB) Put_vs_hidden(v uint32) { + binary.LittleEndian.PutUint32(s[28:32], v) +} + // Get_vs_total_sect returns vs_total_sect. func (s VFATSB) Get_vs_total_sect() uint32 { return binary.LittleEndian.Uint32(s[32:36]) } +// Put_vs_total_sect sets vs_total_sect. +func (s VFATSB) Put_vs_total_sect(v uint32) { + binary.LittleEndian.PutUint32(s[32:36], v) +} + // Get_vs_fat32_length returns vs_fat32_length. func (s VFATSB) Get_vs_fat32_length() uint32 { return binary.LittleEndian.Uint32(s[36:40]) } +// Put_vs_fat32_length sets vs_fat32_length. +func (s VFATSB) Put_vs_fat32_length(v uint32) { + binary.LittleEndian.PutUint32(s[36:40], v) +} + // Get_vs_flags returns vs_flags. func (s VFATSB) Get_vs_flags() uint16 { return binary.LittleEndian.Uint16(s[40:42]) } +// Put_vs_flags sets vs_flags. +func (s VFATSB) Put_vs_flags(v uint16) { + binary.LittleEndian.PutUint16(s[40:42], v) +} + // Get_vs_version returns vs_version. func (s VFATSB) Get_vs_version() []byte { return s[42:44] } +// Put_vs_version sets vs_version. +func (s VFATSB) Put_vs_version(v []byte) { + copy(s[42:44], v) +} + // Get_vs_root_cluster returns vs_root_cluster. func (s VFATSB) Get_vs_root_cluster() uint32 { return binary.LittleEndian.Uint32(s[44:48]) } +// Put_vs_root_cluster sets vs_root_cluster. +func (s VFATSB) Put_vs_root_cluster(v uint32) { + binary.LittleEndian.PutUint32(s[44:48], v) +} + // Get_vs_fsinfo_sector returns vs_fsinfo_sector. func (s VFATSB) Get_vs_fsinfo_sector() uint16 { return binary.LittleEndian.Uint16(s[48:50]) } +// Put_vs_fsinfo_sector sets vs_fsinfo_sector. +func (s VFATSB) Put_vs_fsinfo_sector(v uint16) { + binary.LittleEndian.PutUint16(s[48:50], v) +} + // Get_vs_backup_boot returns vs_backup_boot. func (s VFATSB) Get_vs_backup_boot() uint16 { return binary.LittleEndian.Uint16(s[50:52]) } +// Put_vs_backup_boot sets vs_backup_boot. +func (s VFATSB) Put_vs_backup_boot(v uint16) { + binary.LittleEndian.PutUint16(s[50:52], v) +} + // Get_vs_drive_number returns vs_drive_number. func (s VFATSB) Get_vs_drive_number() byte { return s[76] } +// Put_vs_drive_number sets vs_drive_number. +func (s VFATSB) Put_vs_drive_number(v byte) { + s[76] = v +} + // Get_vs_boot_flags returns vs_boot_flags. func (s VFATSB) Get_vs_boot_flags() byte { return s[77] } +// Put_vs_boot_flags sets vs_boot_flags. +func (s VFATSB) Put_vs_boot_flags(v byte) { + s[77] = v +} + // Get_vs_ext_boot_sign returns 0x28 - without vs_label/vs_magic; 0x29 - with. func (s VFATSB) Get_vs_ext_boot_sign() byte { return s[78] } +// Put_vs_ext_boot_sign sets 0x28 - without vs_label/vs_magic; 0x29 - with. +func (s VFATSB) Put_vs_ext_boot_sign(v byte) { + s[78] = v +} + // Get_vs_serno returns vs_serno. func (s VFATSB) Get_vs_serno() []byte { return s[79:83] } +// Put_vs_serno sets vs_serno. +func (s VFATSB) Put_vs_serno(v []byte) { + copy(s[79:83], v) +} + // Get_vs_label returns vs_label. func (s VFATSB) Get_vs_label() []byte { return s[83:94] } +// Put_vs_label sets vs_label. +func (s VFATSB) Put_vs_label(v []byte) { + copy(s[83:94], v) +} + // Get_vs_magic returns vs_magic. func (s VFATSB) Get_vs_magic() []byte { return s[94:102] } +// Put_vs_magic sets vs_magic. +func (s VFATSB) Put_vs_magic(v []byte) { + copy(s[94:102], v) +} + // Get_vs_dummy2 returns vs_dummy2. func (s VFATSB) Get_vs_dummy2() []byte { return s[102:522] } +// Put_vs_dummy2 sets vs_dummy2. +func (s VFATSB) Put_vs_dummy2(v []byte) { + copy(s[102:522], v) +} + // Get_vs_pmagic returns vs_pmagic. func (s VFATSB) Get_vs_pmagic() []byte { return s[522:524] } +// Put_vs_pmagic sets vs_pmagic. +func (s VFATSB) Put_vs_pmagic(v []byte) { + copy(s[522:524], v) +} + // VFATSB_SIZE is the size of the VFATSB struct. const VFATSB_SIZE = 524 diff --git a/blkid/internal/filesystems/xfs/superblock.go b/blkid/internal/filesystems/xfs/superblock.go index d53b864..5302a7e 100644 --- a/blkid/internal/filesystems/xfs/superblock.go +++ b/blkid/internal/filesystems/xfs/superblock.go @@ -18,230 +18,460 @@ func (s SuperBlock) Get_sb_magicnum() uint32 { return binary.BigEndian.Uint32(s[0:4]) } +// Put_sb_magicnum sets magic number == XFS_SB_MAGIC. +func (s SuperBlock) Put_sb_magicnum(v uint32) { + binary.BigEndian.PutUint32(s[0:4], v) +} + // Get_sb_blocksize returns logical block size, bytes. func (s SuperBlock) Get_sb_blocksize() uint32 { return binary.BigEndian.Uint32(s[4:8]) } +// Put_sb_blocksize sets logical block size, bytes. +func (s SuperBlock) Put_sb_blocksize(v uint32) { + binary.BigEndian.PutUint32(s[4:8], v) +} + // Get_sb_dblocks returns number of data blocks. func (s SuperBlock) Get_sb_dblocks() uint64 { return binary.BigEndian.Uint64(s[8:16]) } +// Put_sb_dblocks sets number of data blocks. +func (s SuperBlock) Put_sb_dblocks(v uint64) { + binary.BigEndian.PutUint64(s[8:16], v) +} + // Get_sb_rblocks returns number of realtime blocks. func (s SuperBlock) Get_sb_rblocks() uint64 { return binary.BigEndian.Uint64(s[16:24]) } +// Put_sb_rblocks sets number of realtime blocks. +func (s SuperBlock) Put_sb_rblocks(v uint64) { + binary.BigEndian.PutUint64(s[16:24], v) +} + // Get_sb_rextents returns number of realtime extents. func (s SuperBlock) Get_sb_rextents() uint64 { return binary.BigEndian.Uint64(s[24:32]) } +// Put_sb_rextents sets number of realtime extents. +func (s SuperBlock) Put_sb_rextents(v uint64) { + binary.BigEndian.PutUint64(s[24:32], v) +} + // Get_sb_uuid returns file system unique id. func (s SuperBlock) Get_sb_uuid() []byte { return s[32:48] } +// Put_sb_uuid sets file system unique id. +func (s SuperBlock) Put_sb_uuid(v []byte) { + copy(s[32:48], v) +} + // Get_sb_logstart returns starting block of log if internal. func (s SuperBlock) Get_sb_logstart() uint64 { return binary.BigEndian.Uint64(s[48:56]) } +// Put_sb_logstart sets starting block of log if internal. +func (s SuperBlock) Put_sb_logstart(v uint64) { + binary.BigEndian.PutUint64(s[48:56], v) +} + // Get_sb_rootino returns root inode number. func (s SuperBlock) Get_sb_rootino() uint64 { return binary.BigEndian.Uint64(s[56:64]) } +// Put_sb_rootino sets root inode number. +func (s SuperBlock) Put_sb_rootino(v uint64) { + binary.BigEndian.PutUint64(s[56:64], v) +} + // Get_sb_rbmino returns bitmap inode for realtime extents. func (s SuperBlock) Get_sb_rbmino() uint64 { return binary.BigEndian.Uint64(s[64:72]) } +// Put_sb_rbmino sets bitmap inode for realtime extents. +func (s SuperBlock) Put_sb_rbmino(v uint64) { + binary.BigEndian.PutUint64(s[64:72], v) +} + // Get_sb_rsumino returns summary inode for rt bitmap. func (s SuperBlock) Get_sb_rsumino() uint64 { return binary.BigEndian.Uint64(s[72:80]) } +// Put_sb_rsumino sets summary inode for rt bitmap. +func (s SuperBlock) Put_sb_rsumino(v uint64) { + binary.BigEndian.PutUint64(s[72:80], v) +} + // Get_sb_rextsize returns realtime extent size, blocks. func (s SuperBlock) Get_sb_rextsize() uint32 { return binary.BigEndian.Uint32(s[80:84]) } +// Put_sb_rextsize sets realtime extent size, blocks. +func (s SuperBlock) Put_sb_rextsize(v uint32) { + binary.BigEndian.PutUint32(s[80:84], v) +} + // Get_sb_agblocks returns size of an allocation group. func (s SuperBlock) Get_sb_agblocks() uint32 { return binary.BigEndian.Uint32(s[84:88]) } +// Put_sb_agblocks sets size of an allocation group. +func (s SuperBlock) Put_sb_agblocks(v uint32) { + binary.BigEndian.PutUint32(s[84:88], v) +} + // Get_sb_agcount returns number of allocation groups. func (s SuperBlock) Get_sb_agcount() uint32 { return binary.BigEndian.Uint32(s[88:92]) } +// Put_sb_agcount sets number of allocation groups. +func (s SuperBlock) Put_sb_agcount(v uint32) { + binary.BigEndian.PutUint32(s[88:92], v) +} + // Get_sb_rbmblocks returns number of rt bitmap blocks. func (s SuperBlock) Get_sb_rbmblocks() uint32 { return binary.BigEndian.Uint32(s[92:96]) } +// Put_sb_rbmblocks sets number of rt bitmap blocks. +func (s SuperBlock) Put_sb_rbmblocks(v uint32) { + binary.BigEndian.PutUint32(s[92:96], v) +} + // Get_sb_logblocks returns number of log blocks. func (s SuperBlock) Get_sb_logblocks() uint32 { return binary.BigEndian.Uint32(s[96:100]) } +// Put_sb_logblocks sets number of log blocks. +func (s SuperBlock) Put_sb_logblocks(v uint32) { + binary.BigEndian.PutUint32(s[96:100], v) +} + // Get_sb_versionnum returns header version == XFS_SB_VERSION. func (s SuperBlock) Get_sb_versionnum() uint16 { return binary.BigEndian.Uint16(s[100:102]) } +// Put_sb_versionnum sets header version == XFS_SB_VERSION. +func (s SuperBlock) Put_sb_versionnum(v uint16) { + binary.BigEndian.PutUint16(s[100:102], v) +} + // Get_sb_sectsize returns volume sector size, bytes. func (s SuperBlock) Get_sb_sectsize() uint16 { return binary.BigEndian.Uint16(s[102:104]) } +// Put_sb_sectsize sets volume sector size, bytes. +func (s SuperBlock) Put_sb_sectsize(v uint16) { + binary.BigEndian.PutUint16(s[102:104], v) +} + // Get_sb_inodesize returns inode size, bytes. func (s SuperBlock) Get_sb_inodesize() uint16 { return binary.BigEndian.Uint16(s[104:106]) } +// Put_sb_inodesize sets inode size, bytes. +func (s SuperBlock) Put_sb_inodesize(v uint16) { + binary.BigEndian.PutUint16(s[104:106], v) +} + // Get_sb_inopblock returns inodes per block. func (s SuperBlock) Get_sb_inopblock() uint16 { return binary.BigEndian.Uint16(s[106:108]) } +// Put_sb_inopblock sets inodes per block. +func (s SuperBlock) Put_sb_inopblock(v uint16) { + binary.BigEndian.PutUint16(s[106:108], v) +} + // Get_sb_fname returns file system name. func (s SuperBlock) Get_sb_fname() []byte { return s[108:120] } +// Put_sb_fname sets file system name. +func (s SuperBlock) Put_sb_fname(v []byte) { + copy(s[108:120], v) +} + // Get_sb_blocklog returns log2 of sb_blocksize. func (s SuperBlock) Get_sb_blocklog() byte { return s[120] } +// Put_sb_blocklog sets log2 of sb_blocksize. +func (s SuperBlock) Put_sb_blocklog(v byte) { + s[120] = v +} + // Get_sb_sectlog returns log2 of sb_sectsize. func (s SuperBlock) Get_sb_sectlog() byte { return s[121] } +// Put_sb_sectlog sets log2 of sb_sectsize. +func (s SuperBlock) Put_sb_sectlog(v byte) { + s[121] = v +} + // Get_sb_inodelog returns log2 of sb_inodesize. func (s SuperBlock) Get_sb_inodelog() byte { return s[122] } +// Put_sb_inodelog sets log2 of sb_inodesize. +func (s SuperBlock) Put_sb_inodelog(v byte) { + s[122] = v +} + // Get_sb_inopblog returns log2 of sb_inopblock. func (s SuperBlock) Get_sb_inopblog() byte { return s[123] } +// Put_sb_inopblog sets log2 of sb_inopblock. +func (s SuperBlock) Put_sb_inopblog(v byte) { + s[123] = v +} + // Get_sb_agblklog returns log2 of sb_agblocks (rounded up). func (s SuperBlock) Get_sb_agblklog() byte { return s[124] } +// Put_sb_agblklog sets log2 of sb_agblocks (rounded up). +func (s SuperBlock) Put_sb_agblklog(v byte) { + s[124] = v +} + // Get_sb_rextslog returns log2 of sb_rextents. func (s SuperBlock) Get_sb_rextslog() byte { return s[125] } +// Put_sb_rextslog sets log2 of sb_rextents. +func (s SuperBlock) Put_sb_rextslog(v byte) { + s[125] = v +} + // Get_sb_inprogress returns mkfs is in progress, don't mount. func (s SuperBlock) Get_sb_inprogress() byte { return s[126] } +// Put_sb_inprogress sets mkfs is in progress, don't mount. +func (s SuperBlock) Put_sb_inprogress(v byte) { + s[126] = v +} + // Get_sb_imax_pct returns max % of fs for inode space. func (s SuperBlock) Get_sb_imax_pct() byte { return s[127] } +// Put_sb_imax_pct sets max % of fs for inode space. +func (s SuperBlock) Put_sb_imax_pct(v byte) { + s[127] = v +} + // Get_sb_icount returns allocated inodes. func (s SuperBlock) Get_sb_icount() uint64 { return binary.BigEndian.Uint64(s[128:136]) } +// Put_sb_icount sets allocated inodes. +func (s SuperBlock) Put_sb_icount(v uint64) { + binary.BigEndian.PutUint64(s[128:136], v) +} + // Get_sb_ifree returns free inodes. func (s SuperBlock) Get_sb_ifree() uint64 { return binary.BigEndian.Uint64(s[136:144]) } +// Put_sb_ifree sets free inodes. +func (s SuperBlock) Put_sb_ifree(v uint64) { + binary.BigEndian.PutUint64(s[136:144], v) +} + // Get_sb_fdblocks returns free data blocks. func (s SuperBlock) Get_sb_fdblocks() uint64 { return binary.BigEndian.Uint64(s[144:152]) } +// Put_sb_fdblocks sets free data blocks. +func (s SuperBlock) Put_sb_fdblocks(v uint64) { + binary.BigEndian.PutUint64(s[144:152], v) +} + // Get_sb_frextents returns free realtime extents. func (s SuperBlock) Get_sb_frextents() uint64 { return binary.BigEndian.Uint64(s[152:160]) } +// Put_sb_frextents sets free realtime extents. +func (s SuperBlock) Put_sb_frextents(v uint64) { + binary.BigEndian.PutUint64(s[152:160], v) +} + // Get_sb_uquotino returns inode for user quotas. func (s SuperBlock) Get_sb_uquotino() uint64 { return binary.BigEndian.Uint64(s[160:168]) } +// Put_sb_uquotino sets inode for user quotas. +func (s SuperBlock) Put_sb_uquotino(v uint64) { + binary.BigEndian.PutUint64(s[160:168], v) +} + // Get_sb_gquotino returns inode for group or project quotas. func (s SuperBlock) Get_sb_gquotino() uint64 { return binary.BigEndian.Uint64(s[168:176]) } +// Put_sb_gquotino sets inode for group or project quotas. +func (s SuperBlock) Put_sb_gquotino(v uint64) { + binary.BigEndian.PutUint64(s[168:176], v) +} + // Get_sb_qflags returns quota flags. func (s SuperBlock) Get_sb_qflags() uint16 { return binary.BigEndian.Uint16(s[176:178]) } +// Put_sb_qflags sets quota flags. +func (s SuperBlock) Put_sb_qflags(v uint16) { + binary.BigEndian.PutUint16(s[176:178], v) +} + // Get_sb_flags returns misc flags. func (s SuperBlock) Get_sb_flags() byte { return s[178] } +// Put_sb_flags sets misc flags. +func (s SuperBlock) Put_sb_flags(v byte) { + s[178] = v +} + // Get_sb_shared_vn returns reserved, zeroed. func (s SuperBlock) Get_sb_shared_vn() byte { return s[179] } +// Put_sb_shared_vn sets reserved, zeroed. +func (s SuperBlock) Put_sb_shared_vn(v byte) { + s[179] = v +} + // Get_sb_inoalignmt returns inode alignment. func (s SuperBlock) Get_sb_inoalignmt() uint32 { return binary.BigEndian.Uint32(s[180:184]) } +// Put_sb_inoalignmt sets inode alignment. +func (s SuperBlock) Put_sb_inoalignmt(v uint32) { + binary.BigEndian.PutUint32(s[180:184], v) +} + // Get_sb_unit returns stripe or raid unit. func (s SuperBlock) Get_sb_unit() uint32 { return binary.BigEndian.Uint32(s[184:188]) } +// Put_sb_unit sets stripe or raid unit. +func (s SuperBlock) Put_sb_unit(v uint32) { + binary.BigEndian.PutUint32(s[184:188], v) +} + // Get_sb_width returns stripe or raid width. func (s SuperBlock) Get_sb_width() uint32 { return binary.BigEndian.Uint32(s[188:192]) } +// Put_sb_width sets stripe or raid width. +func (s SuperBlock) Put_sb_width(v uint32) { + binary.BigEndian.PutUint32(s[188:192], v) +} + // Get_sb_dirblklog returns directory block allocation granularity. func (s SuperBlock) Get_sb_dirblklog() byte { return s[192] } +// Put_sb_dirblklog sets directory block allocation granularity. +func (s SuperBlock) Put_sb_dirblklog(v byte) { + s[192] = v +} + // Get_sb_logsectlog returns log sector sector size. func (s SuperBlock) Get_sb_logsectlog() byte { return s[193] } +// Put_sb_logsectlog sets log sector sector size. +func (s SuperBlock) Put_sb_logsectlog(v byte) { + s[193] = v +} + // Get_sb_logsectsize returns log sector size. func (s SuperBlock) Get_sb_logsectsize() uint16 { return binary.BigEndian.Uint16(s[194:196]) } +// Put_sb_logsectsize sets log sector size. +func (s SuperBlock) Put_sb_logsectsize(v uint16) { + binary.BigEndian.PutUint16(s[194:196], v) +} + // Get_sb_logsunit returns log device stripe or raid unit. func (s SuperBlock) Get_sb_logsunit() uint32 { return binary.BigEndian.Uint32(s[196:200]) } +// Put_sb_logsunit sets log device stripe or raid unit. +func (s SuperBlock) Put_sb_logsunit(v uint32) { + binary.BigEndian.PutUint32(s[196:200], v) +} + // Get_sb_features2 returns additional version flags. func (s SuperBlock) Get_sb_features2() uint32 { return binary.BigEndian.Uint32(s[200:204]) } +// Put_sb_features2 sets additional version flags. +func (s SuperBlock) Put_sb_features2(v uint32) { + binary.BigEndian.PutUint32(s[200:204], v) +} + // Get_sb_bad_features2 returns mirror of sb_features2. func (s SuperBlock) Get_sb_bad_features2() uint32 { return binary.BigEndian.Uint32(s[204:208]) } +// Put_sb_bad_features2 sets mirror of sb_features2. +func (s SuperBlock) Put_sb_bad_features2(v uint32) { + binary.BigEndian.PutUint32(s[204:208], v) +} + // SUPERBLOCK_SIZE is the size of the SuperBlock struct. const SUPERBLOCK_SIZE = 208 diff --git a/blkid/internal/filesystems/zfs/zfsub.go b/blkid/internal/filesystems/zfs/zfsub.go index 711751d..faca486 100644 --- a/blkid/internal/filesystems/zfs/zfsub.go +++ b/blkid/internal/filesystems/zfs/zfsub.go @@ -18,30 +18,60 @@ func (s ZFSUB) Get_ub_magic() uint64 { return binary.LittleEndian.Uint64(s[0:8]) } +// Put_ub_magic sets UBERBLOCK_MAGIC. +func (s ZFSUB) Put_ub_magic(v uint64) { + binary.LittleEndian.PutUint64(s[0:8], v) +} + // Get_ub_version returns SPA_VERSION. func (s ZFSUB) Get_ub_version() uint64 { return binary.LittleEndian.Uint64(s[8:16]) } +// Put_ub_version sets SPA_VERSION. +func (s ZFSUB) Put_ub_version(v uint64) { + binary.LittleEndian.PutUint64(s[8:16], v) +} + // Get_ub_txg returns txg of last sync. func (s ZFSUB) Get_ub_txg() uint64 { return binary.LittleEndian.Uint64(s[16:24]) } +// Put_ub_txg sets txg of last sync. +func (s ZFSUB) Put_ub_txg(v uint64) { + binary.LittleEndian.PutUint64(s[16:24], v) +} + // Get_ub_guid_sum returns sum of all vdev guids. func (s ZFSUB) Get_ub_guid_sum() uint64 { return binary.LittleEndian.Uint64(s[24:32]) } +// Put_ub_guid_sum sets sum of all vdev guids. +func (s ZFSUB) Put_ub_guid_sum(v uint64) { + binary.LittleEndian.PutUint64(s[24:32], v) +} + // Get_ub_timestamp returns UTC time of last sync. func (s ZFSUB) Get_ub_timestamp() uint64 { return binary.LittleEndian.Uint64(s[32:40]) } +// Put_ub_timestamp sets UTC time of last sync. +func (s ZFSUB) Put_ub_timestamp(v uint64) { + binary.LittleEndian.PutUint64(s[32:40], v) +} + // Get_ub_rootbp returns MOS objset_phys_t. func (s ZFSUB) Get_ub_rootbp() byte { return s[40] } +// Put_ub_rootbp sets MOS objset_phys_t. +func (s ZFSUB) Put_ub_rootbp(v byte) { + s[40] = v +} + // ZFSUB_SIZE is the size of the ZFSUB struct. const ZFSUB_SIZE = 41 diff --git a/blkid/internal/partitions/gpt/entry.go b/blkid/internal/partitions/gpt/entry.go index 69e707f..77a7b56 100644 --- a/blkid/internal/partitions/gpt/entry.go +++ b/blkid/internal/partitions/gpt/entry.go @@ -18,30 +18,60 @@ func (s Entry) Get_partition_type_guid() []byte { return s[0:16] } +// Put_partition_type_guid sets type UUID. +func (s Entry) Put_partition_type_guid(v []byte) { + copy(s[0:16], v) +} + // Get_unique_partition_guid returns partition UUID. func (s Entry) Get_unique_partition_guid() []byte { return s[16:32] } +// Put_unique_partition_guid sets partition UUID. +func (s Entry) Put_unique_partition_guid(v []byte) { + copy(s[16:32], v) +} + // Get_starting_lba returns starting_lba. func (s Entry) Get_starting_lba() uint64 { return binary.LittleEndian.Uint64(s[32:40]) } +// Put_starting_lba sets starting_lba. +func (s Entry) Put_starting_lba(v uint64) { + binary.LittleEndian.PutUint64(s[32:40], v) +} + // Get_ending_lba returns ending_lba. func (s Entry) Get_ending_lba() uint64 { return binary.LittleEndian.Uint64(s[40:48]) } +// Put_ending_lba sets ending_lba. +func (s Entry) Put_ending_lba(v uint64) { + binary.LittleEndian.PutUint64(s[40:48], v) +} + // Get_attributes returns attributes. func (s Entry) Get_attributes() uint64 { return binary.LittleEndian.Uint64(s[48:56]) } +// Put_attributes sets attributes. +func (s Entry) Put_attributes(v uint64) { + binary.LittleEndian.PutUint64(s[48:56], v) +} + // Get_partition_name returns partition_name. func (s Entry) Get_partition_name() []byte { return s[56:128] } +// Put_partition_name sets partition_name. +func (s Entry) Put_partition_name(v []byte) { + copy(s[56:128], v) +} + // ENTRY_SIZE is the size of the Entry struct. const ENTRY_SIZE = 128 diff --git a/blkid/internal/partitions/gpt/header.go b/blkid/internal/partitions/gpt/header.go index e20081f..4d25f89 100644 --- a/blkid/internal/partitions/gpt/header.go +++ b/blkid/internal/partitions/gpt/header.go @@ -18,70 +18,140 @@ func (s Header) Get_signature() uint64 { return binary.LittleEndian.Uint64(s[0:8]) } +// Put_signature sets "EFI PART". +func (s Header) Put_signature(v uint64) { + binary.LittleEndian.PutUint64(s[0:8], v) +} + // Get_revision returns revision. func (s Header) Get_revision() uint32 { return binary.LittleEndian.Uint32(s[8:12]) } +// Put_revision sets revision. +func (s Header) Put_revision(v uint32) { + binary.LittleEndian.PutUint32(s[8:12], v) +} + // Get_header_size returns usually 92 bytes. func (s Header) Get_header_size() uint32 { return binary.LittleEndian.Uint32(s[12:16]) } +// Put_header_size sets usually 92 bytes. +func (s Header) Put_header_size(v uint32) { + binary.LittleEndian.PutUint32(s[12:16], v) +} + // Get_header_crc32 returns header_crc32. func (s Header) Get_header_crc32() uint32 { return binary.LittleEndian.Uint32(s[16:20]) } +// Put_header_crc32 sets header_crc32. +func (s Header) Put_header_crc32(v uint32) { + binary.LittleEndian.PutUint32(s[16:20], v) +} + // Get_reserved1 returns reserved1. func (s Header) Get_reserved1() uint32 { return binary.LittleEndian.Uint32(s[20:24]) } +// Put_reserved1 sets reserved1. +func (s Header) Put_reserved1(v uint32) { + binary.LittleEndian.PutUint32(s[20:24], v) +} + // Get_my_lba returns location of this header copy. func (s Header) Get_my_lba() uint64 { return binary.LittleEndian.Uint64(s[24:32]) } +// Put_my_lba sets location of this header copy. +func (s Header) Put_my_lba(v uint64) { + binary.LittleEndian.PutUint64(s[24:32], v) +} + // Get_alternate_lba returns location of the other header copy. func (s Header) Get_alternate_lba() uint64 { return binary.LittleEndian.Uint64(s[32:40]) } +// Put_alternate_lba sets location of the other header copy. +func (s Header) Put_alternate_lba(v uint64) { + binary.LittleEndian.PutUint64(s[32:40], v) +} + // Get_first_usable_lba returns first usable LBA for partitions. func (s Header) Get_first_usable_lba() uint64 { return binary.LittleEndian.Uint64(s[40:48]) } +// Put_first_usable_lba sets first usable LBA for partitions. +func (s Header) Put_first_usable_lba(v uint64) { + binary.LittleEndian.PutUint64(s[40:48], v) +} + // Get_last_usable_lba returns last usable LBA for partitions. func (s Header) Get_last_usable_lba() uint64 { return binary.LittleEndian.Uint64(s[48:56]) } +// Put_last_usable_lba sets last usable LBA for partitions. +func (s Header) Put_last_usable_lba(v uint64) { + binary.LittleEndian.PutUint64(s[48:56], v) +} + // Get_disk_guid returns disk UUID. func (s Header) Get_disk_guid() []byte { return s[56:72] } +// Put_disk_guid sets disk UUID. +func (s Header) Put_disk_guid(v []byte) { + copy(s[56:72], v) +} + // Get_partition_entries_lba returns always 2 in primary header copy. func (s Header) Get_partition_entries_lba() uint64 { return binary.LittleEndian.Uint64(s[72:80]) } +// Put_partition_entries_lba sets always 2 in primary header copy. +func (s Header) Put_partition_entries_lba(v uint64) { + binary.LittleEndian.PutUint64(s[72:80], v) +} + // Get_num_partition_entries returns num_partition_entries. func (s Header) Get_num_partition_entries() uint32 { return binary.LittleEndian.Uint32(s[80:84]) } +// Put_num_partition_entries sets num_partition_entries. +func (s Header) Put_num_partition_entries(v uint32) { + binary.LittleEndian.PutUint32(s[80:84], v) +} + // Get_sizeof_partition_entry returns sizeof_partition_entry. func (s Header) Get_sizeof_partition_entry() uint32 { return binary.LittleEndian.Uint32(s[84:88]) } +// Put_sizeof_partition_entry sets sizeof_partition_entry. +func (s Header) Put_sizeof_partition_entry(v uint32) { + binary.LittleEndian.PutUint32(s[84:88], v) +} + // Get_partition_entry_array_crc32 returns partition_entry_array_crc32. func (s Header) Get_partition_entry_array_crc32() uint32 { return binary.LittleEndian.Uint32(s[88:92]) } +// Put_partition_entry_array_crc32 sets partition_entry_array_crc32. +func (s Header) Put_partition_entry_array_crc32(v uint32) { + binary.LittleEndian.PutUint32(s[88:92], v) +} + // HEADER_SIZE is the size of the Header struct. const HEADER_SIZE = 92