Skip to content
Advertisement

why file with hole has smaller disk block than file without hole?

JavaScript

I’m newbie in unix system programming

There is code making file with hole.

Output result is:

JavaScript

Why file with hole has fewer disk block than file without hole?

In my thinking, file without hole takes smaller disk blocks

Because file with hole is more spreaded than without hole..

From “Advanced Programming in the UNIX Environment 3rd-Stevens Rago, example 3.2”

Advertisement

Answer

Why do you think that a file without hole takes smaller space ? This exactly the contrary. If the file has holes, then it is not necessary to reserve disk blocks for that space. The number of disk blocks is not related to the spreading of the file, but directly related to the size of the data you wrote in the file.

Advertisement