public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Martin Wege <martin.l.wege@gmail.com>
To: "cygwin@cygwin.com" <cygwin@cygwin.com>,
	Corinna Vinschen <corinna-cygwin@cygwin.com>
Subject: Re: How to fix |mkfifo()| failure if |pathname| is on NFS ? / was: Re: [EXTERNAL] Re: mkfifo: cannot set permissions of 'x.fifo': Not a directory
Date: Sat, 26 Aug 2023 19:58:17 +0200	[thread overview]
Message-ID: <CANH4o6PWnPEcadHX9T1TwaS1gPrT-bN3Yy8av4k2Mjc0WAR7ZA@mail.gmail.com> (raw)
In-Reply-To: <CANH4o6MFsCY4awWmo5vcow4_jZKnkoc8A1C72Ub=2OBuyCkRqA@mail.gmail.com>

On Thu, Aug 24, 2023 at 6:45 PM Martin Wege <martin.l.wege@gmail.com> wrote:
>
> On Wed, Aug 23, 2023 at 1:06 AM Roland Mainz via Cygwin
> <cygwin@cygwin.com> wrote:
> >
> > On Tue, Aug 22, 2023 at 4:52 PM Lavrentiev, Anton (NIH/NLM/NCBI) [C]
> > via Cygwin <cygwin@cygwin.com> wrote:
> > > > FIFOs which don't make *any* sense
> > > > ... FWIW, a remote NFS fileystem.
> > >
> > > I got an impression that the OP is trying to deploy something (maybe the entire Cygwin) onto an
> > > NFS share.  So the named FIFO "file" is also created in there.
> >
> > I agree with that impression. This is basically what large sites
> > (universities etc) do with UNIX and Linux: The machines mount an
> > user's ${HOMR} directory via automounter over NFS, and users are
> > discouraged (e.g. grumpy admin visiting you in person, blocking all
> > escape routes... =:-) ) from using the machine's local filesystems (in
> > Cygwin's case that includes "C:"!).
> >
> > In that case people want to use |mkfifo()|/|mkfifoat()| and/or
> > /usr/bin/mkfifo in their home directory, and don't expect that it does
> > not work.
> >
> > But that is what happens on Cygwin 3.4.8 right now, if someone tries
> > to do a |mkfifo()| on a NFS home directory (tested with MS NFSv3 and
> > CITI NFSv4 clients):
> > |mkfifo()| succeeds, but the resulting inode is *NOT* a FIFO as requested
> >
> > Example (/cygdrive/h/ is my home directory shared from my Linux machine):
> > ---- snip ----
> > roland_mainz@winkrakra1 /cygdrive/h/work/cygwin_mkfifo_on_nfs
> > $ uname -a
> > CYGWIN_NT-10.0-19045 winkrakra1 3.4.8-1.x86_64 2023-08-17 17:02 UTC
> > x86_64 Cygwin
> >
> > roland_mainz@winkrakra1 /cygdrive/h/work/cygwin_mkfifo_on_nfs
> > $ mount
> > C:/cygwin64/bin on /usr/bin type ntfs (binary,auto)
> > C:/cygwin64/lib on /usr/lib type ntfs (binary,auto)
> > C:/cygwin64 on / type ntfs (binary,auto)
> > C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto)
> > H: on /cygdrive/h type nfs (binary,posix=0,user,noumount,auto)
> >
> > roland_mainz@winkrakra1 /cygdrive/h/work/cygwin_mkfifo_on_nfs
> > $ ls -l
> > total 1
> > -rw-rw-rw- 1 Unix_User+0 Unix_Group+0 330 Aug 22 23:58 cygwin_mkfifo_on_nfs.c
> >
> > roland_mainz@winkrakra1 /cygdrive/h/work/cygwin_mkfifo_on_nfs
> > $ cat -n cygwin_mkfifo_on_nfs.c
> >      1  #include <stdlib.h>
> >      2  #include <stdio.h>
> >      3  #include <stdio.h>
> >      4  #include <errno.h>
> >      5  #include <sys/types.h>
> >      6  #include <sys/stat.h>
> >      7
> >      8  int main(int ac, char *av[])
> >      9  {
> >     10          (void)puts("# start");
> >     11
> >     12          if
> > (mkfifo("/cygdrive/h/work/cygwin_mkfifo_on_nfs/myfifo.fifo", 0) != 0)
> >     13                  perror("mkfifo failed");
> >     14          (void)puts("# done.");
> >     15          return EXIT_SUCCESS;
> >     16  }
> >     17
> >
> > roland_mainz@winkrakra1 /cygdrive/h/work/cygwin_mkfifo_on_nfs
> > $ gcc -g cygwin_mkfifo_on_nfs.c
> >
> > roland_mainz@winkrakra1 /cygdrive/h/work/cygwin_mkfifo_on_nfs
> > $ ./a
> > # start
> > # done.
> >
> > roland_mainz@winkrakra1 /cygdrive/h/work/cygwin_mkfifo_on_nfs
> > $ ls -l
> > total 68
> > -rwxr-xr-x 1 Unix_User+0 Unix_Group+0 66951 Aug 23 00:12 a.exe
> > -rw-rw-rw- 1 Unix_User+0 Unix_Group+0   330 Aug 22 23:58 cygwin_mkfifo_on_nfs.c
> > lrwxrwxrwx 1 Unix_User+0 Unix_Group+0    11 Aug 23 00:12 myfifo.fifo
> > -> ':\0:c4:1000'
> >
> > roland_mainz@winkrakra1 /cygdrive/h/work/cygwin_mkfifo_on_nfs
> > $ cat <myfifo.fifo
> > -bash: myfifo.fifo: No such file or directory
> > ---- snip ----
> >
> > Note that Cygwin does not interpret the file |myfifo.fifo| as FIFO,
> > instead it comes back as a symlink "myfifo.fifo -> ':\0:c4:1000'".
> >
> > AFAIK there are (at least) these two options to fix the problems:
> > 1. Check whether the filesystem for the fifos path is NFS
> > (cgywin.dll's |fs.fs_is_nfs()|), and if it is a symlink check if it
> > starts with ':\0:c4:' (assuming "c4" is the prefix for inodes created
> > with |mkfifo()|). If this condition is |true|, then cygwin |stat()|,
> > |open()| etc. should treat this inode as FIFO.
> > 2. Check whether the filesystem for the fifos path is NFS
> > (cgywin.dll's |fs.fs_is_nfs()|), and then just refuse |mkfifo()| with
> > |ENOSYS| (not implemented)
> >
> > Better algorithm for [1] might be to check whether the inode is a
> > symlink, and then do a |fs.fs_is_nfs()| on the symlinks |pathname|,
> > assuming this is more performant.
>
> We would like to see option 1 implemented, maybe as an option in the
> CYGWIN environment variable
> (CYGWIN=nfs_emulate_dev_special_files_as_symlink ?)

One problem I see is how we can set machine-wide defaults, as the
CYGWIN variable is only inherited from process to process, and
/usr/bin/env - myprog will start myprog with an empty environment.

So if there is no way to set machine-wide defaults, I would prefer to
have the nfs_emulate_dev_special_files_as_symlink enabled by default.

Thanks,
Martin

  parent reply	other threads:[~2023-08-26 17:58 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-07 14:42 Martin Wege
2023-08-07 18:26 ` Brian Inglis
2023-08-07 19:14   ` Corinna Vinschen
2023-08-07 21:14     ` Martin Wege
2023-08-08  8:20       ` Corinna Vinschen
2023-08-08 19:38         ` Martin Wege
2023-08-09  8:01           ` Corinna Vinschen
2023-08-09  9:12             ` Martin Wege
2023-08-09  9:56               ` Corinna Vinschen
2023-08-10 12:49                 ` Martin Wege
2023-08-18  4:02 ` Martin Wege
2023-08-18  8:34   ` Corinna Vinschen
2023-08-18 13:14     ` Martin Wege
2023-08-21  4:49     ` Cedric Blancher
2023-08-21  8:37       ` Corinna Vinschen
2023-08-22 14:52         ` [EXTERNAL] " Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2023-08-22 23:05           ` How to fix |mkfifo()| failure if |pathname| is on NFS ? / was: " Roland Mainz
2023-08-24 16:45             ` Martin Wege
2023-08-25  4:25               ` Cedric Blancher
2023-08-26 17:58               ` Martin Wege [this message]
2023-08-25 12:18             ` Corinna Vinschen
2023-08-25 12:25               ` Corinna Vinschen
2023-08-26 11:26                 ` Cedric Blancher
2023-08-26 14:15                   ` Corinna Vinschen
2023-08-26 17:40                     ` Martin Wege
2023-08-26 19:16                       ` Brian Inglis
2023-08-25 15:14               ` Roland Mainz
2023-08-26 11:27                 ` Cedric Blancher
2023-08-25 23:21               ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2023-08-26 14:28                 ` Corinna Vinschen
2023-08-26 14:39                   ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2023-08-26 17:44               ` Documenting Cygwin on NFS, no longer only exchange-medium! " Martin Wege
2023-08-26 19:16                 ` Brian Inglis
2023-08-27 12:35                 ` Corinna Vinschen
2023-08-28  5:35                   ` Cedric Blancher
2023-08-28 10:02                     ` Corinna Vinschen
2023-08-28 11:41                   ` Joshuah Hurst
     [not found]           ` <14a692f6-7244-4a7e-a69b-d14521fb01e8@secure-endpoints.com>
2023-08-23 17:39             ` Lavrentiev, Anton (NIH/NLM/NCBI) [C]
2023-08-24  5:28             ` Cedric Blancher
2023-08-24 16:40             ` Martin Wege
2023-08-21 12:12     ` Martin Wege

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANH4o6PWnPEcadHX9T1TwaS1gPrT-bN3Yy8av4k2Mjc0WAR7ZA@mail.gmail.com \
    --to=martin.l.wege@gmail.com \
    --cc=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).