Cygwin: fix chmod on native NFS FIFOs

By handling native NFS FIFOs as actual FIFOs, chmod on a FIFO
suddenly called fhandler_base::fchmod, which is insufficient
to handle FIFO files on any filesystem.

Note that this does not fix Cygwin FIFOs on NFS or AFS yet.

Fixes: 622fb0776e ("Cygwin: enable usage of FIFOs on NFS")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2023-09-08 22:38:53 +02:00
parent 53472e1803
commit bedefff9e2
2 changed files with 12 additions and 3 deletions

View File

@ -613,7 +613,10 @@ fhandler_base::open (int flags, mode_t mode)
options |= FILE_OPEN_REPARSE_POINT;
}
if (get_device () == FH_FS)
/* If the file is a FIFO, open has been called for an operation on the file
constituting the FIFO, e. g., chmod or statvfs. Handle it like a normal
file. Eespecially the access flags have to be set correctly. */
if (get_device () == FH_FS || get_device () == FH_FIFO)
{
/* O_TMPFILE files are created with delete-on-close semantics, as well
as with FILE_ATTRIBUTE_TEMPORARY. The latter speeds up file access,
@ -1710,7 +1713,10 @@ int
fhandler_base::fchmod (mode_t mode)
{
if (pc.is_fs_special ())
return chmod_device (pc, mode);
{
fhandler_disk_file fh (pc);
return fh.fchmod (mode);
}
/* By default, just succeeds. */
return 0;
}

View File

@ -715,7 +715,10 @@ fhandler_disk_file::fchmod (mode_t mode)
NTSTATUS status;
IO_STATUS_BLOCK io;
if (pc.is_fs_special ())
if (pc.is_fs_special ()
/* For NFS, only handle Cygwin FIFOs specially. Changing mode of
native FIFOs will work with the default code below. */
&& (!pc.fs_is_nfs () || pc.nfsattr ()->filler1 == NF3FIFO))
return chmod_device (pc, mode);
if (!get_handle ())