Cygwin: use new _AT_NULL_PATHNAME_ALLOWED flag

Convert gen_full_path_at to take flag values from the caller, rather
than just a bool indicating that empty paths are allowed.  This is in
preparation of a better AT_EMPTY_PATH handling in a followup patch.

Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2023-07-12 13:45:24 +02:00
parent a891dc7605
commit 0051091999
1 changed files with 4 additions and 5 deletions

View File

@ -4416,11 +4416,10 @@ pclose (FILE *fp)
static int static int
gen_full_path_at (char *path_ret, int dirfd, const char *pathname, gen_full_path_at (char *path_ret, int dirfd, const char *pathname,
bool null_pathname_allowed = false) int flags = 0)
{ {
/* Set null_pathname_allowed to true to allow GLIBC compatible behaviour /* futimesat allows a NULL pathname. */
for NULL pathname. Only used by futimesat. */ if (!pathname && !(flags & _AT_NULL_PATHNAME_ALLOWED))
if (!pathname && !null_pathname_allowed)
{ {
set_errno (EFAULT); set_errno (EFAULT);
return -1; return -1;
@ -4678,7 +4677,7 @@ futimesat (int dirfd, const char *pathname, const struct timeval times[2])
__try __try
{ {
char *path = tp.c_get (); char *path = tp.c_get ();
if (gen_full_path_at (path, dirfd, pathname, true)) if (gen_full_path_at (path, dirfd, pathname, _AT_NULL_PATHNAME_ALLOWED))
__leave; __leave;
return utimes (path, times); return utimes (path, times);
} }