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

Re: more coreutils problems


On Jan 25 06:46, Eric Blake wrote:
> It looks like the lstat() call is violating POSIX - it should be checking
> the path prefix, note that `file' is not a directory, and set errno to
> ENOTDIR, but instead it is just setting ENOENT.

I tested the following three situations on Linux and on Cygwin:

  lstat("file/x") with file an existing file
  lstat("dir/x")  with dir an existing directory
  lstat("dir/x")  with dir non-existing.

On linux, the first case sets errno to ENOTDIR, the other two cases set
errno to ENOENT.

On Cygwin, errno is the translated Win32 error code from a call to
GetFileAttributes.  GetFileAttributes results in ERROR_FILE_NOT_FOUND
in the second case, in ERROR_PATH_NOT_FOUND in the first and third case.

So there's no chance to get a 1:1 translation into the correct POSIX
errno except for testing all path components if GetFileAttributes
returns ERROR_PATH_NOT_FOUND until GetFileAttributes succeeds.  Implementing
checking of each parent path component would slow things down incredibly.

> Also, I noticed there is no setpriority() or getpriority(), but nice() is
> provided in <unistd.h> which does the same thing.  It looks like
> winsup/cygwin/syscalls.cc always returns 0 in nice() on success, contrary
> to POSIX (it should be the new nice value, between -NZERO and NZERO-1).
> Furthermore, there is no definition of NZERO in <limits.h>, but POSIX
> requires it to be defined, and at least 20, if nice() is implemented.
> Ultimately, `nice nice' should print 10, not 0.  But since Windows only
> provides 4 priority levels, cygwin should maintain a separate "nice value"
> per process that is mapped into Windows values, something like: -20 to
> - -11, -10 to -1, 0 to 9, and 10 to 19.  That would make 'nice 1 nice' print
> 1, but not change the process priority; but 'nice nice' would print 10 and
> lower the priority.

On Linux, nice(2) also only returns 0 in case of success and -1 otherwise.
If somebody needs to retrieve the nice value, she's pointed to getpriority.
I'm going to implement setpriority/getpriority and leave the nice(2)
return codes as on Linux.


Corinna

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

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.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]