This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Get recursive grep to work on Win9x


There have been various reports over time that recursive grep is not
working on Win9x. For every directory you get a 'Permission denied'
error.
Also there have been reports that using open(2) to open a directory
readonly on Win9x fails.
Both have the same cause.

open(2) calls _open in the cygwin1.dll (See source file syscalls.cc).
When you open a file (or directory) it creates a file_handler
and calls fhandler_base::open (See source file fhandler.cc).
fhandler_base::open adds the FILE_FLAG_BACKUP_SEMANTICS to
the file_attributes for the Win32 CreateFile call in case you
open a directory.
This way of opening a directory is only supported on WinNT and not
on Win9x. See MSDN.
Hence the reports that grep -R works on NT and not on 9x.

To get grep to work on 9x, the fix is simple: get fhandler_base::open
to set the error EISDIR when you try to open a directory.
This is *not* strictly POSIX. According to POSIX open should only
return EISDIR when you try to open a directory read/write or writeonly.
However it fixes the problem for grep.

The patch is simple. It makes use of the wincap.can_open_directories()
capability, which seems to be foreseen for exactly this type of problems.
However I could not find an other place where this capability is used
in the cygwin.dll.

Patch attached: fhandler.diff

Attachment: fhandler.diff
Description: application/unknown-content-type-diff_auto_file


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]