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: 622fb0776e
("Cygwin: enable usage of FIFOs on NFS")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
8a953be5ef
commit
c0aa6ac30e
|
@ -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))
|
||||
{
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue