Cygwin: fsync: Fix EINVAL for block device.

The commit af8a7c13b5 has a problem that fsync returns EINVAL for
block device. This patch treats block devices as a special case.
https://cygwin.com/pipermail/cygwin/2023-January/252916.html

Fixes: af8a7c13b5 ("Cygwin: fsync: Return EINVAL for special files.")
Reported-by: Yano Ray <yanorei@hotmail.co.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
This commit is contained in:
Takashi Yano 2023-01-21 21:33:03 +09:00
parent 3123fdeecb
commit bdb9f5b173
2 changed files with 7 additions and 1 deletions

View File

@ -1728,7 +1728,8 @@ fhandler_base::utimens (const struct timespec *tvp)
int
fhandler_base::fsync ()
{
if (!get_handle () || nohandle () || pc.isspecial ())
if (!get_handle () || nohandle ()
|| (pc.isspecial () && !S_ISBLK (pc.dev.mode ())))
{
set_errno (EINVAL);
return -1;

View File

@ -0,0 +1,5 @@
Bug Fixes
---------
Fix a problem that fsync returns EINVAL for block device.
Addresses: https://cygwin.com/pipermail/cygwin/2023-January/252916.html