2

When I run the command ls // is Cygwin, the shell hangs for about 12 seconds, then gives the error ls: reading directory '//': Permission denied. I remember reading somewhere that /some//path is interpreted the same as /some/path in POSIX paths, and accordingly, when I run the command in an Ubuntu virtual machine, there is no delay, and ls outputs the contents of /.

I can't find anything about // in the Cygwin special filenames documentation, so why does this happen, and how can I reduce the delay?

Edit:

It turns out \\* paths are network paths on Windows. When I disconnect my computer from all networks, ls \\ returns an empty listing immediately. When I connect to a some networks, I get a listing of hosts on the network, but on other networks, I encounter the problem described above. Considering this, is the some way to configure Windows so that the delay is reduced, even in the case of a permission error?

1
  • I can't reproduce this here. ls // returns instantly and no files are listed.
    – DavidPostill
    Commented Mar 23, 2016 at 16:17

3 Answers 3

2

It’s not a Cygwin issue, it’s a Unix issue.  In the early days of computer networking, before Sun (Solaris) introduced the /net/hostname syntax for accessing remote filesystems1, and NFS allowed remote filesystems to be mounted at arbitrary mount points (e.g., /mnt or /home/username), some versions of Unix implemented a //hostname/pathname syntax for the same purpose.  See On what systems is //foo/bar different from /foo/bar?  Over the years, that syntax has fallen out of favor, yielding (mostly?) to NFS.

However, to allow these legacy systems to be POSIX-compliant, the standard explicitly allows // to mean something different from / (at the beginning of a path):

If a pathname begins with two successive <slash> characters, the first component following the leading <slash> characters may be interpreted in an implementation-defined manner, although more than two leading <slash> characters shall be treated as a single <slash> character.
        (from near the end of the “Pathname Resolution” section)

— although it doesn’t specify what it should mean (if anything).

Cygwin interprets // much the same as the old /net, as documented here.  It references Windows’ “Network” (pseudo-)folder — the one that contains “This Computer” and other discoverable machines.

See also Unix: difference between path starting with / and //.
____________
1 … and, optionally, /net could be listed to produce a list of the names of accessible hosts with exported filesystems — i.e., fileservers.

0

https://cygwin.com/cygwin-ug-net/using.html#unc-paths

There's also a virtual directory // which allows to enumerate the fileservers known to the local machine with ls.

0

On my computer, ls // also runs slowly, printing a couple of cannot access '//some-computer-name': No such file or directory, and in the end printing a few computer names. These are Windows PCs on the local network, and apparently ls tries to connect to them (don't know what for).

On the other hand, dir \\ runs quickly and prints the same computer names (no error messages).

I don't think there's a way to configure Windows to prevent that, looks to me like a Cygwin issue (or feature). Best thing would be to write to Cygwin's mailing list about that, asking to fix it.

Anyway, can I ask why do you run ls // at all?

6
  • I don't run ls // directly, but my editor, Kakoune, presumably runs it whenever I type // in order to suggest filenames for completion. You can imagine how hanging for over 10 seconds every time I type // might be problematic.
    – Vaelus
    Commented Apr 20, 2016 at 15:39
  • You mean any time you write // to start a comment in your code, your editor tries to offer filename completion? Otherwise, where/why do you have to write // for filename completion? Commented Apr 20, 2016 at 19:04
  • Exactly, whenever I have to write a C++ style comment, my editor tries to offer filename completion. Obviously I can turn of filename completion in my editor, but in every other case, filename completion is pretty handy, so I'd like to avoid that.
    – Vaelus
    Commented Apr 20, 2016 at 19:08
  • I don't get it, why do you need filename completion in C++ code? Have you tried asking the editor's author to change the // behavior by default or as an option? Commented Apr 20, 2016 at 19:23
  • Filename completion is useful, for instance, in #include directives. I have not tried asking the editor's author, but really, this seems like a Cygwin problem, so I'll probably ask on Cygwin's mailing list, like you suggested, for either a fix or a workaround.
    – Vaelus
    Commented Apr 20, 2016 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .