public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Orgad Shaneh <orgads@gmail.com>
To: cygwin@cygwin.com
Subject: Re: FindFirstFile fails for some network directories
Date: Wed, 19 Aug 2015 05:46:00 -0000	[thread overview]
Message-ID: <CAGHpTB+O-Z3Mir-4ZV7Wmh3dqo=rqfy+-CAW_KCE2hQdCjhB5w@mail.gmail.com> (raw)
In-Reply-To: <CAGHpTBKEWFa8M1KN6_vqrBT6WOjVpmOCUqP-LHBYK=FApg2fJg@mail.gmail.com>

On Mon, Aug 17, 2015 at 3:03 PM, Orgad Shaneh <orgads@gmail.com> wrote:
> Hi,
>
> I have 2 network shares with similar contents:
> \\netapp1\CM\CompilationResults
> \\aclnas01\versions\CompilationResults
>
> Trying to list all the files within these directories using Ruby
> succeeds for netapp1, but fails for aclnas01.
>
> The failing ruby command is:
>   ruby -e "print Dir.glob('//aclnas01/versions/CompilationResults/*')"
>
> The exact same command succeeds when executed from a normal command
> prompt, or when the directory is on netapp1 (on both shells).
>
> After debugging Ruby, I found out that FindFirstFile returns an
> INVALID_HANDLE when invoked from cygwin environment.
>
> The following application succeeds on command prompt and fails on cygwin:
>
> #include <stdio.h>
> #include <windows.h>
>
> int main()
> {
>     const TCHAR *aclnas = TEXT("//aclnas01/versions/CompilationResults");
>     const TCHAR *netapp = TEXT("//netapp1/CM/CompilationResults");
>
>     WIN32_FIND_DATA fd;
>     printf("%d\n", FindFirstFile(aclnas, &fd) !=
> INVALID_HANDLE_VALUE); // Fails on cygwin
>     printf("%d\n", FindFirstFile(netapp, &fd) !=
> INVALID_HANDLE_VALUE); // Always succeeds
>     return 0;
> }
>
> Output on cmd is 1 1, on cygwin it is 0 1.
>
> Process Monitor shows that when executed from cygwin, CreateFile is
> called with Open for Backup flag. I can't say for sure if this causes
> the failure, but that's the only difference I could find between these
> executions.
>
> This bug was previously reported on github/msys2[1], but it wasn't solved.
>
> I only have read access to these servers, but I might have cooperation
> of the sys admin (can't promise though).
>
> Any help will be appreciated.
>
> Thanks,
> - Orgad
>
> [1] https://github.com/Alexpux/MSYS2-packages/issues/242

Hi,

Using Wireshark, I discovered that aclnas01 uses SMB, while netapp1 uses SMB2.

For some reason, when executed from command prompt, a FIND_FIRST2
request is sent and the server replies, while with cygwin a "NT Create
AndX" request is sent and denied.

To minimize the captured packets, I executed the application twice,
and captured only the second execution (to avoid session initiation).

Working capture: https://gist.github.com/orgads/d2681881668afb9cb08f
Failing capture: https://gist.github.com/orgads/4f0ea2b26cfd64f4353d

Does cygwin implement SMB on its own, or is this difference a
side-effect of the "Backup Intent" flag?

- Orgad

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

  reply	other threads:[~2015-08-19  5:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-17 12:03 Orgad Shaneh
2015-08-19  5:46 ` Orgad Shaneh [this message]
2015-08-19  6:28   ` Orgad Shaneh
2015-12-09  9:43     ` Orgad Shaneh
2015-12-09 10:46       ` Corinna Vinschen

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='CAGHpTB+O-Z3Mir-4ZV7Wmh3dqo=rqfy+-CAW_KCE2hQdCjhB5w@mail.gmail.com' \
    --to=orgads@gmail.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).