Paul Eggert wrote:
>  int
>  fchmodat (int dir, char const *file, mode_t mode, int flags)
>  {
> +  if (file && *file)
> +    flags &= ~AT_EMPTY_PATH;
> +  else if (! (flags & AT_EMPTY_PATH))
> +    {
> +      errno = ENOENT;
> +      return -1;
> +    }
> +  else if (! (flags & AT_SYMLINK_NOFOLLOW))
> +    return fchmod (dir, mode);

Shouldn't the last line read

       return fchmod (dir == AT_FDCWD ? "." : dir, mode);

? Rationale: The man page [1] says

       AT_EMPTY_PATH (since Linux 6.6)
              If path is an empty string, operate on the file referred to
              by dirfd (which may have been obtained using the open(2)
              O_PATH flag).  In this case, dirfd can refer to any type of
              file, not just a directory.  If dirfd is AT_FDCWD, the call
              operates on the current working directory.  This flag is
              Linux-specific; define _GNU_SOURCE to obtain its
              definition.

Bruno

[1] https://man7.org/linux/man-pages/man2/fchmodat.2.html




Reply via email to