This is the mail archive of the cygwin@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]

Re: cygwin 1.3.3 - fchdir() problem?


On Tue, Sep 18, 2001 at 12:50:12PM +0200, Uwe H. Steinfeld wrote:
> open (somedir, O_RDONLY) always gives error 13 (permission denied) if
> somedir exists, and error 2 (no such file or directory) otherwise.
> 
> This is standard Win32 (mis-)behavior. From MS documentation:
> A return value of -1 indicates an error, in which case errno is set to one
> of the following values:
> EACCES Tried to open read-only file for writing, or file's sharing mode does
> not allow specified operations, or given path is directory

Also quoted from MSDN:

    Windows NT/2000 or later: You can obtain a handle to a directory by
    setting the FILE_FLAG_BACKUP_SEMANTICS flag. A directory handle can
    be passed to some functions in place of a file handle.

Did you actually try it using the below test application in Cygwin?
Or are you talking about 9x?  Then you've lost, naturally.

Corinna

> 
> Danke
> Uwe
> 
> ----- Original Message -----
> From: "Corinna Vinschen" <cygwin@cygwin.com>
> To: <cygwin@cygwin.com>
> Sent: Monday, September 17, 2001 10:29 PM
> Subject: Re: cygwin 1.3.3 - fchdir() problem?
> 
> 
> > On Mon, Sep 17, 2001 at 09:59:30PM +0200, Uwe H. Steinfeld wrote:
> > > I tracked my problem down to the following:
> > > when fchdir is defined and the directory to be created or removed is not
> a
> > > subdirectory of the current working directory, fileutils try to do an
> > >     open (".", O_RDONLY | O_DIRECTORY)
> > > and that is never successful in Cygwin/Win32.
> >
> > Beep! Try this:
> >
> >     #include <stdio.h>
> >     #include <errno.h>
> >     #include <sys/fcntl.h>
> >
> >     int
> >     main (int argc, char **argv)
> >     {
> >       int fd;
> >
> >       if ((fd = open (".", O_RDONLY)) < 0)
> > printf ("NOPE: %d\n", errno);
> >       else
> > {
> >   printf ("YEP\n");
> >   close (fd);
> > }
> >       return 0;
> >     }
> >
> > O_DIRECTORY isn't defined on Cygwin.  According to the Linux man
> > pages it's a Linux invention to avoid denial-of-service problems
> > with opendir().  Especially it "should not be used outside of the
> > implementation of opendir."
> >
> > Corinna
> 
> 
> 
> --
> Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
> Bug reporting:         http://cygwin.com/bugs.html
> Documentation:         http://cygwin.com/docs.html
> FAQ:                   http://cygwin.com/faq/

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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