Branch data Line data Source code
1 : : #include "precizer.h"
2 : :
3 : : /**
4 : : * @brief Convert POSIX `st_blocks` units into bytes.
5 : : *
6 : : * @details POSIX defines `st_blocks` in 512-byte units regardless of the
7 : : * filesystem I/O block size. Some filesystems may report non-positive values
8 : : * for special files; those are normalized to zero.
9 : : *
10 : : * @param blocks Allocated block count from file metadata.
11 : : * @return Allocated bytes as `blocks * POSIX_STAT_BLOCK_BYTES`, or zero when
12 : : * @p blocks is less than or equal to zero.
13 : : */
14 : 3694 : extern inline size_t blocks_to_bytes(const blkcnt_t blocks)
15 : : {
16 [ + + ]: 3694 : if(blocks <= 0)
17 : : {
18 : 20 : return 0;
19 : : }
20 : :
21 : 3674 : return (size_t)blocks * POSIX_STAT_BLOCK_BYTES;
22 : : }
|