test -r or -x always return false on an NFS mount?

Ken Brown kbrown@cornell.edu
Tue Oct 6 01:41:17 GMT 2020

On 10/1/2020 6:22 AM, Mario Emmenlauer wrote:
> On 22.09.20 22:14, Mario Emmenlauer wrote:
>> But since today I met a problem: I mounted a Linux NFSv3 share using
>> the Windows 10 shipped NFS client. The user and group ID are mapped
>> via registry settings AnonymousUid and AnonymousGid in the entry
>> HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default
>> Everything seems to work quite well, and in `ls -la` I can see the
>> file permissions and user and group entries. But when using `test`
>> to check for read (`test -r`) or execute permissions (`test -x`), it
>> always returns false, even for readable files. `ls` on the other hand
>> shows the permissions correctly, and `cat`ing the files works without
>> problems.
>> I've read https://cygwin.com/cygwin-ug-net/using-filemodes.html
>> about the Cygwin file permissions for NFS, and also the NFS account
>> mapping at https://cygwin.com/cygwin-ug-net/ntsec.html#ntsec-mapping-nfs,
>> but as far as I can see, they are both unrelated. Google turned up no
>> useful hits for keywords "cygwin" "test" and "nfs", so I'm a bit at the
>> end of my wit.
>> Is this a known issue, and/or are there any workarounds? I'm currently
>> using `test -e` in place of read or execute checks, but it basically
>> breaks all my build scripts.
> Is there something I should do about this issue? I could look into the
> source code of `test` on Cygwin if someone can point me to the correct
> repository? Or should I just file an issue?

There is no special source code of 'test' on Cygwin.  Assuming you're working in 
a bash shell, 'test' is a shell builtin, so the source code is part of the 
source code of bash.  (I don't know if other shells have a 'test' builtin.) 
Alternatively, if you're running /usr/bin/test.exe, then it's part of the 
coreutils package.

Either way, looking at that source code is not likely to help, except to see 
what system call it uses to test the access.

> The issue is not a super high priority for me personally, but I guess
> its quite a limitation of Cygwin if essential scripting functionality
> is misbehaving on NFS.

I don't know anything about NFS, but I doubt if this is a general problem with 
NFS on Cygwin.  There's quite a bit of Cygwin code devoted to NFS shares, and 
the question is why this isn't working for yours.

Corinna is probably the only person who knows what questions to ask you to get 
to the bottom of this, and she's currently unavailable.  When she returns, maybe 
she can help.


More information about the Cygwin mailing list