Subject: misc/14515: shmget manpage proposes the use of IPC_R, IPC_W, ... to set flags
To: None <gnats-bugs@gnats.netbsd.org>
From: None <hendrik@scholz.net>
List: netbsd-bugs
Date: 11/09/2001 12:54:51
>Number:         14515
>Category:       misc
>Synopsis:       shmget manpage proposes the use of IPC_R, IPC_W, ... to set flags
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people
>State:          open
>Class:          doc-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 09 12:56:01 PST 2001
>Closed-Date:
>Last-Modified:
>Originator:     Hendrik Scholz
>Release:        NetBSD 1.5Y
>Organization:
NetUSE AG
>Environment:
tBSD phobos 1.5Y NetBSD 1.5Y (PHOBOS) #0: Tue Nov  6 09:18:27 UTC 2001     hscholz@phobos:/usr/src/sys/arch/sgimips/compile/PHOBOS sgimips

>Description:
The shmget manpage says:

"
     and nine bits of access bits, based on:

           IPC_R  read permission

           IPC_W  write permission

           IPC_M  changing control info permission
"

I wrote a simple program to return the appropriate value but that doesn't work because of this code in /usr/include/sys/ipc.h:

#ifdef _KERNEL
[...]

/* Common access type bits, used with ipcperm(). */
#define IPC_R       000400  /* read permission */
#define IPC_W       000200  /* write/alter permission */
#define IPC_M       010000  /* permission to change control info */

[...]
#endif /* _KERNEL */

_KERNEL is not set by default. Using the SHM_R, SHM_W flags works instead.


>How-To-Repeat:
Try to compile this program:

#include <stdio.h>
#include <sys/shm.h>

void main()
{
    printf("%s\n", IPC_R);
}

make foo
cc -O2   -o foo foo.c 
foo.c: In function `main':
foo.c:6: `IPC_R' undeclared (first use in this function)
foo.c:6: (Each undeclared identifier is reported only once
foo.c:6: for each function it appears in.)
*** Error code 1

>Fix:
Use SHM_R, SHM_W, ... istead of IPC_?. The manpage should be updated.

>Release-Note:
>Audit-Trail:
>Unformatted: