MCPcopy Create free account
hub / github.com/coreutils/coreutils / nonexistent_file_errno

Function nonexistent_file_errno

src/remove.c:329–354  ·  view source on GitHub ↗

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. */

Source from the content-addressed store, hash-verified

327 value of ERRNUM, return true if the specified file system object
328 is guaranteed not to exist; otherwise, return false. */
329static inline bool
330nonexistent_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. */
357static inline bool

Callers 1

ignorable_missingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected