diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2023-09-10 00:23:52 +0300 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2023-09-10 00:28:55 +0300 |
commit | c0aa6ac30ec483ad6da6af701625e7aea7536663 (patch) | |
tree | 4fc1c6f354941c5b74c2dca7c5dced1f227a50e3 /winsup | |
parent | 8a953be5ef761d4c5cc0572eab3da2cb34b0474b (diff) |
Cygwin: NFS: create devices (especially FIFOs) as shortcut files
Creating real NFS symlinks for device files has a major downside:
The way we store device info requires to change the symlink target
in case of calling chmod(2). This falls flat in two ways:
- It requires to remove and recreate the symlink, so it doesn't
exist for a short period of time, and
- removing fails badly if there's another open handle to the symlink.
Therefore, change this to create FIFOs as shortcut files, just as on
most other filesystems. Make sure to recognize these new shortcuts
on NFS (for devices only) in path handling and readdir.
Fixes: 622fb0776ea3 ("Cygwin: enable usage of FIFOs on NFS")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/fhandler/disk_file.cc | 18 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 12 |
2 files changed, 26 insertions, 4 deletions
diff --git a/winsup/cygwin/fhandler/disk_file.cc b/winsup/cygwin/fhandler/disk_file.cc index 0242cae2f..245e9bb75 100644 --- a/winsup/cygwin/fhandler/disk_file.cc +++ b/winsup/cygwin/fhandler/disk_file.cc @@ -2348,9 +2348,11 @@ go_ahead: And, since some filesystems choke on the EAs, we don't use them unconditionally. */ f_status = (dir->__flags & dirent_nfs_d_ino) - ? NtCreateFile (&hdl, READ_CONTROL, &attr, &io, - NULL, 0, FILE_SHARE_VALID_FLAGS, - FILE_OPEN, FILE_OPEN_FOR_BACKUP_INTENT, + ? NtCreateFile (&hdl, + READ_CONTROL | FILE_READ_ATTRIBUTES, + &attr, &io, NULL, 0, + FILE_SHARE_VALID_FLAGS, FILE_OPEN, + FILE_OPEN_FOR_BACKUP_INTENT, &nfs_aol_ffei, sizeof nfs_aol_ffei) : NtOpenFile (&hdl, READ_CONTROL, &attr, &io, FILE_SHARE_VALID_FLAGS, @@ -2364,6 +2366,16 @@ go_ahead: FILE_INTERNAL_INFORMATION fii; f_status = NtQueryInformationFile (hdl, &io, &fii, sizeof fii, FileInternalInformation); + /* On NFS fetch the (faked, but useful) DOS attribute. + We need it to recognize shortcut FIFOs. */ + if ((dir->__flags & dirent_nfs_d_ino)) + { + FILE_BASIC_INFORMATION fbi; + + if (NT_SUCCESS (NtQueryInformationFile (hdl, &io, &fbi, + sizeof fbi, FileBasicInformation))) + FileAttributes = fbi.FileAttributes; + } NtClose (hdl); if (NT_SUCCESS (f_status)) { diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 6cf6e02ca..0c9d3921a 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2005,7 +2005,7 @@ symlink_worker (const char *oldpath, path_conv &win32_newpath, bool isdevice) variable. Device files are always shortcuts. */ wsym_type = isdevice ? WSYM_lnk : allow_winsymlinks; /* NFS has its own, dedicated way to create symlinks. */ - if (win32_newpath.fs_is_nfs ()) + if (win32_newpath.fs_is_nfs () && !isdevice) wsym_type = WSYM_nfs; /* MVFS doesn't handle the SYSTEM DOS attribute, but it handles the R/O attribute. Therefore we create symlinks on MVFS always as shortcuts. */ @@ -3477,6 +3477,16 @@ restart: else if (contents[0] != ':' || contents[1] != '\\' || !parse_device (contents)) break; + if (fs.is_nfs () && major == _major (FH_FIFO)) + { + conv_hdl.nfsattr ()->type = NF3FIFO; + conv_hdl.nfsattr ()->mode = mode; + conv_hdl.nfsattr ()->size = 0; + /* Marker for fhandler_base::fstat_by_nfs_ea not to override + the cached fattr3 data with fresh data from the filesystem, + even if the handle is used for other purposes than stat. */ + conv_hdl.nfsattr ()->filler1 = NF3FIFO; + } } /* If searching for `foo' and then finding a `foo.lnk' which is |