且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在特定的文件系统上限制文件大小?

更新时间:2023-11-29 13:55:34

文件系统的文件大小限制通常由包含其文件的变量的大小决定尺寸。在大小定义为32位无符号整数的文件系统中,您将无法存储大小超过2 ^ 32-1(= 4294967295)个字节的文件。在许多现代文件系统中,文件大小通常以64位的形式存储,其最大文件大小为2 ^ 64(16 EiB),是一个非常大的数字。

的文件系统本身通常受到文件系统块的地址大小乘以文件系统块大小的限制。在旧的FAT16文件系统中,地址被限制为16位(= 65536个唯一地址),块(或簇)大小被限制为最大64kB,这导致最大文件系统大小限制为4GB,这就是更大的变体, FAT32,开发了。在NTFS,ext4,btrfs等现代文件系统中,最大文件系统的大小非常大,不可能在很长的时间内被击中。但是,由于实现的限制,在某些情况下,有一些仿真限制低于实际的格式限制,例如NTFS的文件系统大小限制为256TB(根据***)。


  • How the file size is limited on a specific file system?
  • What factors affects it ?

can any one give the details .. I can not find it in the net.

The file size limit of a filesystem is generally decided by the size of the variable containing its file size. In a filesystem where the size is defined as a 32 bit unsigned integer you will not be able to store a file larger than 2^32-1 (=4294967295) bytes in size. On many modern filesystems file size is commonly stored as 64 bits which gives a maximum file size of 2^64 (16 EiB), a very large number.

The maximum size of the filesystem itself is generally limited by the size of the addresses of the filesystem blocks times the filesystem block size. On old FAT16 filesystems the addresses were limited to 16 bits (=65536 unique addresses) and block (or cluster) size were limited to maximum 64kB, this led to the limit of 4GB maximum filesystem size, this was the reason that a larger variant, FAT32, was developed. On modern filesystems such as NTFS, ext4, btrfs, and many others the maximum filesystem size is very large and not likely to be hit in a long time. However, because of limitations in the implementations, there are some artificial limits that are lower than the actual format limit in some cases, for example NTFS has a filesystem size limit of 256TB (according to Wikipedia).