public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "Michael Kerrisk (man-pages)" <mtk.manpages@gmail.com>
To: Alejandro Colomar <alx.manpages@gmail.com>
Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org,
	libc-alpha@sourceware.org
Subject: Re: [PATCH 3/3] open.2: Remove unused <sys/stat.h>
Date: Mon, 10 May 2021 08:02:12 +1200	[thread overview]
Message-ID: <4d093c28-120b-ecf6-3671-b00159d15da1@gmail.com> (raw)
In-Reply-To: <20210421224418.143065-3-alx.manpages@gmail.com>

Hello Alex,

On 4/22/21 10:44 AM, Alejandro Colomar wrote:
> I can't see a reason to include it.  <fcntl.h> provides O_*
> constants for 'flags', S_* constants for 'mode', and mode_t.
> 
> Probably a long time ago, some of those weren't defined in
> <fcntl.h>, and both headers needed to be included, or maybe it's
> a historical error.
> 
> Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>

So, I am uncertain what to do about this patch. I agree
that we don't need the <sys/stat.h> on Linux.

But, look at open(3p):

    SYNOPSIS
       #include <sys/stat.h>
       #include <fcntl.h>

       int open(const char *path, int oflag, ...);

       O_CREAT       [...] and the access permission bits  (see
                     <sys/stat.h>)  of  the file mode shall be set to the
                     value of the argument following the  oflag  argument
                     taken  as type mode_t modified as follows...

But, seemingly in contradiction, fcntl.h(0p) says:

       The <fcntl.h> header shall define the symbolic constants for  file
       modes for use as values of mode_t as described in <sys/stat.h>.

It almost seems like a small bug in POSIX.

I see also that open(2) on FreeBSD mentions only the need to 
include <fcntl.h>.

What are your thoughts on the above. I'm willing to apply your 
patch if you still think we should apply it.

Thanks,

Michael

> ---
>  man2/open.2 | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/man2/open.2 b/man2/open.2
> index bac1ee806..1bcd995f4 100644
> --- a/man2/open.2
> +++ b/man2/open.2
> @@ -53,7 +53,6 @@
>  open, openat, creat \- open and possibly create a file
>  .SH SYNOPSIS
>  .nf
> -.B #include <sys/stat.h>
>  .B #include <fcntl.h>
>  .PP
>  .BI "int open(const char *" pathname ", int " flags );
> 


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/

  reply	other threads:[~2021-05-09 20:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21 22:44 [PATCH 1/3] alloc_hugepages.2, arch_prctl.2, capget.2, clone.2, delete_module.2, execveat.2, exit_group.2, get_robust_list.2, getunwind.2, init_module.2: Add note about the use of syscall(2) Alejandro Colomar
2021-04-21 22:44 ` [PATCH 2/3] Various pages: Remove unused <sys/ipc.h> (and <sys/types.h>) Alejandro Colomar
2021-05-09 19:54   ` Michael Kerrisk (man-pages)
2021-04-21 22:44 ` [PATCH 3/3] open.2: Remove unused <sys/stat.h> Alejandro Colomar
2021-05-09 20:02   ` Michael Kerrisk (man-pages) [this message]
2021-05-09 20:09     ` Alejandro Colomar (man-pages)
2021-05-09 19:52 ` [PATCH 1/3] alloc_hugepages.2, arch_prctl.2, capget.2, clone.2, delete_module.2, execveat.2, exit_group.2, get_robust_list.2, getunwind.2, init_module.2: Add note about the use of syscall(2) Michael Kerrisk (man-pages)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4d093c28-120b-ecf6-3671-b00159d15da1@gmail.com \
    --to=mtk.manpages@gmail.com \
    --cc=alx.manpages@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).