bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: errno from open(<directory>) ?


From: Bruno Haible
Subject: Re: errno from open(<directory>) ?
Date: Mon, 22 May 2017 22:38:07 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-75-generic; KDE/5.18.0; x86_64; ; )

Tim Rühsen wrote:
> > > on GNU/Linux open() on a directory returns -1 and sets errno to EISDIR.
> > 
> > No, for example on my platform (Fedora 25 x86-64), 'strace cat .'
> > outputs the line 'open(".", O_RDONLY) = 3'.
> 
> Same here on Debian unstable.
> What you want to say is, that it depends on the flags.
> And you are right, I wasn't very precise in that point.
> 
> Here we use
> fd = open(fname, O_WRONLY | flag | O_CREAT | O_NONBLOCK | O_BINARY, S_IRUSR | 
> S_IWUSR | S_IRGRP | S_IROTH);
> 
> 'flag' might be one of O_TRUNC, O_APPEND or O_EXCL.
> 
> A test with different flags for open(<existing directory>) shows failure + 
> errno EISDIR when opening for writing.

This portability issue is an ideal "skills ramp up" for someone who has only 
done
smaller contributions to gnulib so far.

Steps:
1) Consider the standards: What does POSIX:2008 say about the issue?
2) Extend the unit test of module 'open'.
3) Ask us to test these extended unit tests on various platforms (Mac OS X, 
Solaris,
   FreeBSD, HP-UX, etc.).
4) Mention the issue in the doc section about 'open'.
5) Extend the Autoconf test to recognize this case and arrange to override the
   'open' function when the Autoconf test fails.
6) Extend the workaround (lib/open.c) and make sure the unit test now succeeds
   on the relevant platform(s).

Any takers? Tim? Gisle?

Bruno




reply via email to

[Prev in Thread] Current Thread [Next in Thread]