Commit Graph

18 Commits

Author SHA1 Message Date
David Sterba 35614d8a64 btrfs-progs: sb-mod: add syntax to the help text
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2020-10-20 15:49:07 +02:00
David Sterba bd017ce732 btrfs-progs: sb-mod: add remaining dev_item members
Add helpers and all remaining members of the device item embedded in the
superblock. No UUID types.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2020-10-20 15:49:07 +02:00
David Sterba 8de6816b47 btrfs-progs: sb-mod: add dev_item prefix for sb::device members
For parity with output of 'btrfs inspect dump-super', add the
"dev_item." prefix to the devid member. This allows adding more
members without conflicts (like it would be for device total_bytes).

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2020-10-20 15:49:07 +02:00
Anand Jain c875145cb3 btrfs-progs: sb-mod: add devid to the modifiable list
We need this patch to create a crafted image with bogus devid.

For example:
./btrfs-sb-mod devid =0

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2020-10-20 15:49:07 +02:00
David Sterba 772f0da6df btrfs-progs: move disk-io.c to kernel-shared/
Signed-off-by: David Sterba <dsterba@suse.com>
2020-08-31 17:01:05 +02:00
Johannes Thumshirn c04bcdcacc btrfs-progs: move crc32c implementation to crypto/
With the introduction of xxhash64 to btrfs-progs we created a crypto/
directory for all the hashes used in btrfs (although no
cryptographically secure hash is there yet).

Move the crc32c implementation from kernel-lib/ to crypto/ as well so we
have all hashes consolidated.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-11-18 19:20:02 +01:00
Johannes Thumshirn a7e2f17a84 btrfs-progs: unbreak btrfs-sb-mod compilation
Fix compiler warnings and errors in btrfs-sb-mod due to incorrect
conversion with the checksum updates.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:31:19 +02:00
Johannes Thumshirn ed33908b44 btrfs-progs: update checksumming api
Update the checksumming API to be able to cope with more checksum types
than just CRC32C. The finalization call is merged into btrfs_csum_data.

There are some fixme's and asserts added that need to be resolved.

Co-developed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:28:34 +02:00
Johannes Thumshirn 926e9c8e14 btrfs-progs: sb-mod: simplify update_block_csum()
update_block_csum() in btrfs-sb-mod.c is always called with the 'is_sb'
argument set to 1.

Get rid of the special case for is_sb == 0.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:28:31 +02:00
Johannes Thumshirn 7b4f1035a6 btrfs-progs: pass checksum type to btrfs_csum_data()/btrfs_csum_final()
In preparation to supporting new checksum algorithm pass the checksum type
to btrfs_csum_data/btrfs_csum_final, this allows us to encapsulate any
differences in processing into the respective functions

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:28:28 +02:00
Johannes Thumshirn de68086e35 btrfs-progs: don't assume checksums are always 4 bytes
Pass pointer to a generic buffer instead of fixed size that crc32c
currently uses.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-14 17:28:25 +02:00
David Sterba 7797f03924 btrfs-progs: sb-mod: add remaining superblock integer items
Add support for changing all integer items in the superblock. Sort them
in the order of defintion in the structure.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:01 +02:00
David Sterba 5ab79b808a btrfs-progs: sb-mod: add remaining integer value types
The field type bit width is now only used to describe the members, but
let's add all of the integer ones.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-04 15:36:01 +02:00
David Sterba 94fced6353 btrfs-progs: build: drop kernel-lib from -I and update paths
Include the files by full path to avoid any confusion in case of
potentially duplicate names.

Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:04 +02:00
David Sterba e3ada5752c btrfs-progs: sb-mod: add compat bit to the recognized fields
Signed-off-by: David Sterba <dsterba@suse.com>
2018-04-11 15:37:36 +02:00
David Sterba 22d39a9e0f btrfs-progs: sb-mod: add csum_type
Let SET and GET work on superblock::csum_type.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-04-11 15:37:36 +02:00
David Sterba b5e0ca64a4 btrfs-progs: sb-mod: add preliminary support for non-u64 types
Signed-off-by: David Sterba <dsterba@suse.com>
2018-04-11 15:37:36 +02:00
David Sterba d04d25fb14 btrfs-progs: add tool to edit super blocks
$ make btrfs-sb-mod
$ ./btrfs-sb-mod image field1 operation1 ...

Fields (only u64 supported for now):
 * total_bytes
 * root
 * generation
 * chunk_root
 * chunk_root_generation
 * cache_generation
 * uuid_tree_generation

Operations:
 * read value		?0
 * set value		=NUMBER
 * add to		+NUMBER
 * subtract from value	-NUMBER
 * xor with value	^NUMBER
 * byteswap (u64)	@0

Use with care!

Signed-off-by: David Sterba <dsterba@suse.com>
2018-03-30 22:15:55 +02:00