1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 19:47:45 +00:00

shred:bitwise method to set OPTIMAL_IO_BLOCK_SIZE

The value of the variable remains unchanged (4096 = 2 ^ 12), but using a
bitwise expression provides two benefits:

- follows the same approach used for configuring BLOCK_SIZE

- indicates that a power-of-two value is preferred for this kind of
  constant
This commit is contained in:
Alexander Shirokov 2025-05-12 09:36:36 +02:00
parent 9fce1a1529
commit 24d88d777a
No known key found for this signature in database
GPG key ID: 6020E4D7AFA8ECE7

View file

@ -49,11 +49,11 @@ const NAME_CHARSET: &[u8] = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMN
const PATTERN_LENGTH: usize = 3;
const PATTERN_BUFFER_SIZE: usize = BLOCK_SIZE + PATTERN_LENGTH - 1;
/// Optimal block size for the filesystem. This constant is used for data size alignment,
/// similar to the behavior of GNU shred. Usually, optimal block size is a 4K block, which is why
/// Optimal block size for the filesystem. This constant is used for data size alignment, similar
/// to the behavior of GNU shred. Usually, optimal block size is a 4K block (2^12), which is why
/// it's defined as a constant. However, it's possible to get the actual size at runtime using, for
/// example, `std::os::unix::fs::MetadataExt::blksize()`.
const OPTIMAL_IO_BLOCK_SIZE: usize = 4096;
const OPTIMAL_IO_BLOCK_SIZE: usize = 1 << 12;
/// Patterns that appear in order for the passes
///