如何在Linux中用C快速创建大文件?

Following this question: How to quickly create large files in C?

I remember 4-5 years ago, I was able to use fallocate shell utility in Linux to create files without holes/gaps.

磁盘文件系统是ext3,ext4或xfs。

At that time, fallocate shell utility created files of 8 GB in less one second. I do not remember if file was full of zeroes or random.

我现在尝试复制此文件,但似乎创建带有漏洞/空白的文件。

I am wondering how this was done in C language?

  • 某些内核调用仅是Linux?
  • 某些内核调用中的规范错误后来被修复?
  • 一些内核调用不再可用?