Domanda

Consider the following command

tar acf file.tar.gz file-5.16 --checkpoint=1 --blocking-factor=50 \
  --checkpoint-action='ttyout=%u\r'

Here is the size of the input folder

$ du -bs file-5.16
2520025 file-5.16

Now with this command a checkpoint is passed every record, and a record in this case is
50 * 512 bytes = 25,600 bytes. It follows that 2520025 / 25600 ≈ 98 checkpoints. So why am I getting

109

As the output?

È stato utile?

Soluzione

To start, you cannot just take the total bytes in the folder and divide it. You must work with the individual files. For each file you need to

ceil(bytes / 512) + 1 = blocks

The plus one is because each file has an extra block

at the end of the file there's a block containing all zeros

§ 9.4 Blocking

After that you add the blocks for all files and divide by the blocking factor, in this case 50

ceil(blocks / 50) = records

Some demo code

$ find file-5.16 -type f |
    xargs du -B512 --apparent-size |
    perl -MPOSIX -ane '$bk += $F[0]+1; END {print ceil $bk/50}'
109
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top