linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: fcntl for mingw
       [not found]   ` <200912111638.17976.bruno-nWNVUoHt2MvYtjvyW6yDsg@public.gmane.org>
@ 2009-12-15  5:16     ` Eric Blake
       [not found]       ` <4B271BAA.2060802-PGZyUNKar/Q@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Blake @ 2009-12-15  5:16 UTC (permalink / raw)
  To: Bruno Haible
  Cc: bug-gnulib-mXXj517/zsQ, mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w,
	linux-man-u79uwXL29TY76Z2rM5mHXA

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bruno Haible on 12/11/2009 8:38 AM:
>> +  switch (action)
>> +    {
>> +    case F_DUPFD_CLOEXEC:
>> +      {
>> +        int target = va_arg (arg, int);
> 
> Is the arg of type 'int' or 'long'? POSIX says it's an 'int'. But
> the Linux man page
>   <http://www.kernel.org/doc/man-pages/online/pages/man2/fcntl.2.html>
> says it's 'long' "in most cases", and indeed glibc's fcntl.c implementation
> uses a 'void *', that is, the same as a 'long'.

That's (hopefully) a bug in the Linux man page.  The return type is int,
and since the arg is an fd and the return type an fd, they had better be
the same type.  But all the same, I'm cc'ing the man page maintainer.

> 
> It makes a difference on big-endian 64-bit platforms (SPARC64, PPC64),

No one writes fcntl(fd,F_DUPFD,1L), since that is contrary to POSIX; and
if fcntl(fd,F_DUPFD,1) doesn't work, then that is a bug in the kernel.

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9-PGZyUNKar/Q@public.gmane.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksnG6oACgkQ84KuGfSFAYB5XwCbBQlPvrRFn/z1/NXXYl6gf52Y
KukAn2DGKBcBEkojl7R3gZZ7uLB0kNao
=AEwR
-----END PGP SIGNATURE-----
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: fcntl for mingw
       [not found]       ` <4B271BAA.2060802-PGZyUNKar/Q@public.gmane.org>
@ 2012-03-24  3:49         ` Michael Kerrisk (man-pages)
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Kerrisk (man-pages) @ 2012-03-24  3:49 UTC (permalink / raw)
  To: Eric Blake
  Cc: Bruno Haible, bug-gnulib-mXXj517/zsQ,
	linux-man-u79uwXL29TY76Z2rM5mHXA

Hello,

On Tue, Dec 15, 2009 at 6:16 PM, Eric Blake <ebb9-PGZyUNKar/Q@public.gmane.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> According to Bruno Haible on 12/11/2009 8:38 AM:
>>> +  switch (action)
>>> +    {
>>> +    case F_DUPFD_CLOEXEC:
>>> +      {
>>> +        int target = va_arg (arg, int);
>>
>> Is the arg of type 'int' or 'long'? POSIX says it's an 'int'. But
>> the Linux man page
>>   <http://www.kernel.org/doc/man-pages/online/pages/man2/fcntl.2.html>
>> says it's 'long' "in most cases", and indeed glibc's fcntl.c implementation
>> uses a 'void *', that is, the same as a 'long'.
>
> That's (hopefully) a bug in the Linux man page.  The return type is int,
> and since the arg is an fd and the return type an fd, they had better be
> the same type.  But all the same, I'm cc'ing the man page maintainer.

Who is finally responding.

>> It makes a difference on big-endian 64-bit platforms (SPARC64, PPC64),
>
> No one writes fcntl(fd,F_DUPFD,1L), since that is contrary to POSIX; and
> if fcntl(fd,F_DUPFD,1) doesn't work, then that is a bug in the kernel.

Agreed. And POSIX explicitly says "int" for various other F_* commands
as well. I think in every case, where the man page says "long" it
should probably say "int". (I think the man page was written from the
kernel-source perspective, where everything really is "long", but I
would likewise consider this a bug if the user needed to specify "1L"
and so on.)

I have applied the patch below for man-pages-3.38. Comments welcome.

Thanks,

Michael

diff --git a/man2/fcntl.2 b/man2/fcntl.2
index b2a985a..4b1b14f 100644
--- a/man2/fcntl.2
+++ b/man2/fcntl.2
@@ -82,7 +82,7 @@ Whether or not this argument is required is determined by
 The required argument type is indicated in parentheses after each
 .I cmd
 name (in most cases, the required type is
-.IR long ,
+.IR int ,
 and we identify the argument using the name
 .IR arg ),
 or
@@ -90,7 +90,7 @@ or
 is specified if the argument is not required.
 .SS "Duplicating a file descriptor"
 .TP
-.BR F_DUPFD " (\fIlong\fP)"
+.BR F_DUPFD " (\fIint\fP)"
 Find the lowest numbered available file descriptor
 greater than or equal to
 .I arg
@@ -106,7 +106,7 @@ See
 .BR dup (2)
 for further details.
 .TP
-.BR F_DUPFD_CLOEXEC " (\fIlong\fP; since Linux 2.6.24)"
+.BR F_DUPFD_CLOEXEC " (\fIint\fP; since Linux 2.6.24)"
 As for
 .BR F_DUPFD ,
 but additionally set the
@@ -139,7 +139,7 @@ Read the file descriptor flags;
 .I arg
 is ignored.
 .TP
-.BR F_SETFD " (\fIlong\fP)"
+.BR F_SETFD " (\fIint\fP)"
 Set the file descriptor flags to the value specified by
 .IR arg .
 .SS "File status flags"
@@ -166,7 +166,7 @@ Get the file access mode and the file status flags;
 .I arg
 is ignored.
 .TP
-.BR F_SETFL " (\fIlong\fP)"
+.BR F_SETFL " (\fIint\fP)"
 Set the file status flags to the value specified by
 .IR arg .
 File access mode
@@ -455,7 +455,7 @@ process group IDs are returned as negative values
(but see BUGS below).
 .I arg
 is ignored.
 .TP
-.BR F_SETOWN " (\fIlong\fP)"
+.BR F_SETOWN " (\fIint\fP)"
 Set the process ID or process group ID that will receive
 .B SIGIO
 and
@@ -663,7 +663,7 @@ the signal handler if installed with
 .I arg
 is ignored.
 .TP
-.BR F_SETSIG " (\fIlong\fP)"
+.BR F_SETSIG " (\fIint\fP)"
 Set the signal sent when input or output becomes possible
 to the value given in
 .IR arg .
@@ -774,7 +774,7 @@ or
 .BR truncate (2)
 the file referred to by that file descriptor.
 .TP
-.BR F_SETLEASE " (\fIlong\fP)"
+.BR F_SETLEASE " (\fIint\fP)"
 Set or remove a file lease according to which of the following
 values is specified in the integer
 .IR arg :
@@ -912,7 +912,7 @@ that has been accessed by another process.
 (This is useful if the caller holds leases against multiple files).
 .SS "File and directory change notification (dnotify)"
 .TP
-.BR F_NOTIFY " (\fIlong\fP)"
+.BR F_NOTIFY " (\fIint\fP)"
 (Linux 2.4 onward)
 Provide notification when the directory referred to by
 .I fd
@@ -1004,7 +1004,7 @@ See
 .BR inotify (7).
 .SS "Changing the capacity of a pipe"
 .TP
-.BR F_SETPIPE_SZ " (\fIlong\fP; since Linux 2.6.35)"
+.BR F_SETPIPE_SZ " (\fIint\fP; since Linux 2.6.35)"
 Change the capacity of the pipe referred to by
 .I fd
 to be at least


-- 
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Author of "The Linux Programming Interface"; http://man7.org/tlpi/
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-03-24  3:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <loom.20091211T001536-796@post.gmane.org>
     [not found] ` <200912111638.17976.bruno@clisp.org>
     [not found]   ` <200912111638.17976.bruno-nWNVUoHt2MvYtjvyW6yDsg@public.gmane.org>
2009-12-15  5:16     ` fcntl for mingw Eric Blake
     [not found]       ` <4B271BAA.2060802-PGZyUNKar/Q@public.gmane.org>
2012-03-24  3:49         ` Michael Kerrisk (man-pages)

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 NNTP newsgroup(s).