fstatat: extend tests and documentation

Document the fstatat behaviour leading to a ENOENT errno, and extend
tests to test the case where filename does not exist.

Signed-off-by: Matteo Croce <teknoraver@meta.com>
This commit is contained in:
Matteo Croce 2025-06-14 11:59:03 +02:00 committed by Adhemerval Zanella
parent 6afece738c
commit 652c36b3ea
3 changed files with 13 additions and 0 deletions

View File

@ -52,6 +52,12 @@ fstat_check (int fd, const char *path, struct stat *st)
static void
fstatat_check (int fd, const char *path, struct stat *st)
{
TEST_COMPARE (fstatat (fd, "", st, 0), -1);
TEST_COMPARE (errno, ENOENT);
TEST_COMPARE (fstatat (AT_FDCWD, "_non_existing_file", st, 0), -1);
TEST_COMPARE (errno, ENOENT);
TEST_COMPARE (fstatat (fd, path, st, 0), 0);
}

View File

@ -56,6 +56,9 @@ fstatat_check (int fd, const char *path, struct stat *st)
TEST_COMPARE (fstatat (fd, "", st, 0), -1);
TEST_COMPARE (errno, ENOENT);
TEST_COMPARE (fstatat (AT_FDCWD, "_non_existing_file", st, 0), -1);
TEST_COMPARE (errno, ENOENT);
TEST_COMPARE (fstatat (fd, path, st, 0), 0);
}

View File

@ -2398,6 +2398,10 @@ The @var{flags} argument is not valid for this function.
@item ENOTDIR
The descriptor @var{filedes} is not associated with a directory, and
@var{filename} is a relative file name.
@item ENOENT
The file named by @var{filename} does not exist, or @var{filename} is an
empty string and @var{flags} does not contain @code{AT_EMPTY_PATH}.
@end table
When the sources are compiled with @code{_FILE_OFFSET_BITS == 64} this