I'm working on a toy filesystem that has hard limitations both on the total number of files and the number of inodes within a directory. What is the correct ERRNO to set in these cases? I wasn't able to access my FAT32-formatted flash drive through WSL, so I can't check by creating a bunch of empty files/folders on a FAT32 instance.
CodePudding user response:
The best solution is likely to be the error code EDQUOT, here are excerpts from the error descriptions of the mkdir and creat system functions:
mkdir: EDQUOT - The user's quota of disk blocks or inodes on the filesystem has been exhausted.
open, creat: EDQUOT - Where O_CREAT is specified, the file does not exist, and the user's quota of disk blocks or inodes on the filesystem has been exhausted.
General description of this error (man errno):
EDQUOT - Disk quota exceeded (POSIX.1-2001).
CodePudding user response:
If the device cannot create a file because of resource shortage (inode, blocks or another structural limitation), the correct error is ENOSPC
: No space left on device.
If the limitation is related to the user and would be lifted for another user including root, the appropriate errno value would be EDQUOT
: Disk quota exceeded.