[Previous]
[Contents]
[Next]

qnx_segment_flags()

change the access flags for a segment

Synopsis:

#include <sys/seginfo.h>
unsigned qnx_segment_flags( unsigned segment,
                            unsigned flags );

Description:

The qnx_segment_flags() function allows you to change the access flags on segment. In order to change the flags, the _PMF_MODIFY flag must be set. If you pass a segment to another process with this flag clear, it's unable to change the access mode. This is useful if you wish to pass read-only access to a segment. Some flag bits are maintained by the system and may never be changed using this function.

The following special flags are supported:

_PMF_DATA_RW
The segment is a read/write data segment.
_PMF_DATA_R
The segment is a read-only data segment.
_PMF_CODE_RX
The segment is a readable executable segment.
_PMF_CODE_X
The segment is a nonreadable executable segment.
_PMF_MODIFY
If this flag isn't set, you're unable to modify the flags again. It must have been set in the system for this call to succeed.

Returns:

segment on success. On error, it returns -1, and errno is set.

Errors:

EINVAL
The segment doesn't exist.
EPERM
You don't have _PMF_MODIFY set on the segment.

Examples:

#include <i86.h>
#include <sys/seginfo.h>

void main()
  {
    unsigned base;
    char __far *p;

    /* Allocate a 32 Kbyte buffer */
    base = qnx_segment_alloc( 32768 );

    /* Point at byte 16,000 in the array */
    p = MK_FP( base, 16000 );

    /* Set and then read a byte in the buffer */
    *p = 'a';

    /* Make the buffer read only */
    qnx_segment_flags( base, _PMF_DATA_R );
    printf( "*p = %c\n", *p );

    /*
     * In protected mode, attempting to write this
     * buffer now causes a memory violation.
     */
    *p = 'a';
  }

Classification:

QNX

Safety:
Interrupt handler No
Signal handler Yes, but modifies errno
Thread Yes

See also:

errno, qnx_segment_alloc(), qnx_segment_alloc_flags(), qnx_segment_arm(), qnx_segment_free(), qnx_segment_get(), qnx_segment_huge(), qnx_segment_index(), qnx_segment_info(), qnx_segment_overlay_flags(), qnx_segment_overlay(), qnx_segment_put(), qnx_segment_raw_alloc(), qnx_segment_raw_free(), qnx_segment_realloc()


[Previous]
[Contents]
[Next]