When a function like unlink, rmdir, or fstatat fails with an errno value of ERRNUM, return true if the specified file system object is guaranteed not to exist; otherwise, return false. */
| 327 | value of ERRNUM, return true if the specified file system object |
| 328 | is guaranteed not to exist; otherwise, return false. */ |
| 329 | static inline bool |
| 330 | nonexistent_file_errno (int errnum) |
| 331 | { |
| 332 | /* Do not include ELOOP here, since the specified file may indeed |
| 333 | exist, but be (in)accessible only via too long a symlink chain. |
| 334 | Likewise for ENAMETOOLONG, since rm -f ./././.../foo may fail |
| 335 | if the "..." part expands to a long enough sequence of "./"s, |
| 336 | even though ./foo does indeed exist. |
| 337 | |
| 338 | Another case to consider is when a particular name is invalid for |
| 339 | a given file system. In 2011, smbfs returns EINVAL, but the next |
| 340 | revision of POSIX will require EILSEQ for that situation: |
| 341 | https://austingroupbugs.net/view.php?id=293 |
| 342 | */ |
| 343 | |
| 344 | switch (errnum) |
| 345 | { |
| 346 | case EILSEQ: |
| 347 | case EINVAL: |
| 348 | case ENOENT: |
| 349 | case ENOTDIR: |
| 350 | return true; |
| 351 | default: |
| 352 | return false; |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | /* Encapsulate the test for whether the errno value, ERRNUM, is ignorable. */ |
| 357 | static inline bool |