


     mmap(LSB.os/mfiles)  LSB-OS (The Open Group)  mmap(LSB.os/mfiles)



     NAME
	  LSB.os/mfiles/mmap - map pages of memory testset

     DESCRIPTION
	  Tests	the mmap() function for	conformance to System
	  Interfaces and Headers, Issue	5 Page:	mmap().
	  These	tests are NOTINUSE for LSB testing since they use
	  shared memory	objects	which are not required in the LSB
	  specification. The main testset is the mmap_P	testset.

     TESTS
     Compliance
	  1    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A successful call to mmap() when fildes is associated
		 with a	shared memory object, the MAP_SHARED flag is
		 set in	flags, and the PROT_READ flag is set in	prot
		 shall map len bytes at	offset off in the file
		 associated with fildes	into the address space of the
		 process, allow	the mapped area	to be read, and	return
		 the location in the address space at which the
		 mapping is made.

	  2    For UNIX98:
		   This	assertion is mandatory
	       For POSIX96:
		   This	assertion is optional (the implementation may
		   not support MAP_PRIVATE and may return ENOTSUP).
	       If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A successful call to mmap() when fildes is associated
		 with a	shared memory object, the MAP_PRIVATE flag is
		 set in	flags, and the PROT_READ flag is set in	prot
		 shall map len bytes at	offset off in the file
		 associated with fildes	into the address space of the
		 process, allow	the mapped area	to be read, and	return
		 the location in the address space at which the
		 mapping is made.

	  3    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation supports the use of PROT_EXEC:
		 A successful call to mmap() when fildes is associated
		 with a	shared memory object, the MAP_SHARED flag is
		 set in	flags, and the PROT_EXEC flag is set in	prot
		 shall map len bytes at	offset off in the file
		 associated with fildes	into the address space of the
		 process, allow	the mapped area	to be executed,	and
		 return	the location in	the address space at which the



     Page 1					    (printed 2/21/103)






     mmap(LSB.os/mfiles)  LSB-OS (The Open Group)  mmap(LSB.os/mfiles)



		 mapping is made.

	  4    For UNIX98:
		   This	assertion is mandatory
	       For POSIX96:
		   This	assertion is optional (the implementation may
		   not support MAP_PRIVATE and may return ENOTSUP).
	       If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation supports the use of PROT_EXEC:
		 A successful call to mmap() when fildes is associated
		 with a	shared memory object, the MAP_PRIVATE flag is
		 set in	flags, and the PROT_EXEC flag is set in	prot
		 shall map len bytes at	offset off in the file
		 associated with fildes	into the address space of the
		 process, allow	the mapped area	to be executed,	and
		 return	the location in	the address space at which the
		 mapping is made.

	  5    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A successful call to mmap() when fildes is associated
		 with a	shared memory object, the MAP_SHARED flag is
		 set in	flags, and the PROT_NONE flag is set in	prot
		 shall map len bytes at	offset off in the file
		 associated with fildes	into the address space of the
		 process, not allow the	mapped area to be accessed,
		 and return the	location in the	address	space at which
		 the mapping is	made.

	  6    For UNIX98:
		   This	assertion is mandatory
	       For POSIX96:
		   This	assertion is optional (the implementation may
		   not support MAP_PRIVATE and may return ENOTSUP).
	       If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A successful call to mmap() when fildes is associated
		 with a	shared memory object, the MAP_PRIVATE flag is
		 set in	flags, and the PROT_NONE flag is set in	prot
		 shall map len bytes at	offset off in the file
		 associated with fildes	into the address space of the
		 process, not allow the	mapped area to be accessed,
		 and return the	location in the	address	space at which
		 the mapping is	made.

	  7    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:



     Page 2					    (printed 2/21/103)






     mmap(LSB.os/mfiles)  LSB-OS (The Open Group)  mmap(LSB.os/mfiles)



		 A successful call to mmap() when fildes is associated
		 with a	shared memory object, the MAP_SHARED flag is
		 set in	flags, and the PROT_WRITE flag is set in prot
		 shall map len bytes at	offset off in the file
		 associated with fildes	into the address space of the
		 process, allow	the mapped area	to be written such
		 that write references change the file,	and return the
		 location in the address space at which	the mapping is
		 made.

	  8    For UNIX98:
		   This	assertion is mandatory
	       For POSIX96:
		   This	assertion is optional (the implementation may
		   not support MAP_PRIVATE and may return ENOTSUP).
	       If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A successful call to mmap() when fildes is associated
		 with a	shared memory object, the MAP_PRIVATE flag is
		 set in	flags, and the PROT_WRITE flag is set in prot
		 shall map len bytes at	offset off in the file
		 associated with fildes	into the address space of the
		 process, allow	the mapped area	to be written such
		 that write references do not change the file, and
		 return	the location in	the address space at which the
		 mapping is made.

	  9    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A successful call to mmap() when fildes is associated
		 with a	shared memory object, the MAP_SHARED flag is
		 set in	flags, and the PROT_READ and PROT_WRITE	flags
		 are set in prot shall map len bytes at	offset off in
		 the file associated with fildes into the address
		 space of the process, allow the mapped	area to	be
		 read and written, and return the location in the
		 address space at which	the mapping is made.

	  10   For UNIX98:
		   This	assertion is mandatory
	       For POSIX96:
		   This	assertion is optional (the implementation may
		   not support MAP_PRIVATE and may return ENOTSUP).
	       If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A successful call to mmap() when fildes is associated
		 with a	shared memory object, the MAP_PRIVATE flag is
		 set in	flags, and the PROT_READ and PROT_WRITE	flags
		 are set in prot shall map len bytes at	offset off in



     Page 3					    (printed 2/21/103)






     mmap(LSB.os/mfiles)  LSB-OS (The Open Group)  mmap(LSB.os/mfiles)



		 the file associated with fildes into the address
		 space of the process, allow the mapped	area to	be
		 read and written, and return the location in the
		 address space at which	the mapping is made.

	  11   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation supports MAP_FIXED:
		 A call	to mmap() when fildes is associated with a
		 shared	memory object and the MAP_FIXED	flag is	set in
		 flags shall cause the file associated with fildes to
		 be mapped at an address exactly matching addr.

	  12   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() shall	zero-fill any partial page at
		 the end of the	shared memory object.

	  13   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 The system shall not write out	modified portions of
		 the last page of a shared memory object mapped	by a
		 call to mmap()	which are beyond the end of the	shared
		 memory	object.

	  14   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 References to mapped pages beyond the page containing
		 the last byte of a shared memory object mapped	by a
		 call to mmap()	shall result in	the delivery of	a
		 SIGBUS	signal.

	  15   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 After a successful call to mmap() for a shared	memory
		 object	the mapping created shall be retained across a
		 fork.

	  16   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 After a successful call to mmap() for a shared	memory
		 object	a subsequent close operation shall not affect
		 the mapping and changes made to the memory image
		 shall be reflected in the mapped portion of the
		 shared	memory object when the changes would have been
		 performed in the absence of the close operation.



     Page 4					    (printed 2/21/103)






     mmap(LSB.os/mfiles)  LSB-OS (The Open Group)  mmap(LSB.os/mfiles)



	  17   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 After a call to mmap()	when MAP_SHARED	is set in
		 flags write references	made to	the memory region
		 shall be visible in all MAP_SHARED mappings of	the
		 same portion of the shared memory object by any
		 process.

	  18   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation supports MAP_PRIVATE:
		 After a call to mmap()	with MAP_PRIVATE set in	flags
		 write references to the memory	region by the calling
		 process shall not be visible to any process in	other
		 mappings of the same portion of the shared memory
		 object.

	  19   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation supports MAP_PRIVATE:
		 A call	to mmap() when MAP_PRIVATE is set in flags and
		 write references are made to the memory region	shall
		 not change the	shared memory object.

	  20   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 The mapping established by a call to mmap() for a
		 shared	memory object shall replace any	previous
		 mappings for those whole pages	containing any part of
		 the address space of the process starting at pa and
		 continuing for	len bytes.

     Deviance
	  21   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() when fildes is not a valid file
		 descriptor shall return MAP_FAILED and	set errno to
		 EBADF.

	  22   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() for a	shared memory object when
		 fildes	is not open for	reading, regardless of the
		 protection specified, shall return MAP_FAILED and set
		 errno to EACCES.




     Page 5					    (printed 2/21/103)






     mmap(LSB.os/mfiles)  LSB-OS (The Open Group)  mmap(LSB.os/mfiles)



	  23   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() for a	shared memory object when
		 fildes	is not open for	writing	and PROT_WRITE is
		 specified for a MAP_SHARED operation shall return
		 MAP_FAILED and	set errno to EACCES.

	  24   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() for a	shared memory object when
		 flags does not	contain	either MAP_PRIVATE or
		 MAP_SHARED shall return MAP_FAILED and	set errno to
		 EINVAL.

	  25   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation provides a file type for which mmap is
	       not supported:
		 A call	to mmap() when fildes refers to	an object for
		 which mmap() is not supported shall return MAP_FAILED
		 and set errno to ENODEV.

	  26   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation supports MAP_FIXED:
		 A call	to mmap() for a	shared memory object when
		 MAP_FIXED is not specified and	there is insufficient
		 room in the address space to effect the mapping.

	  27   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation does not support some of the possibly
	       valid values for	prot:
		 A call	to mmap() for a	shared memory object when the
		 implementation	does not support the combination of
		 accesses requested in prot shall return MAP_FAILED
		 and set errno to ENOTSUP.

	  28   For UNIX98:
		   This	assertion is notinuse as MAP_FIXED must	be
		   supported.
	       If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation does not support MAP_FIXED:
		 A call	to mmap() for a	shared memory object when
		 MAP_FIXED is specified	and the	implementation does



     Page 6					    (printed 2/21/103)






     mmap(LSB.os/mfiles)  LSB-OS (The Open Group)  mmap(LSB.os/mfiles)



		 not support this functionality	shall return
		 MAP_FAILED and	set errno to ENOTSUP.

	  29   For UNIX98:
		   This	assertion is notinuse as MAP_PRIVATE must be
		   supported.
	       If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation does not support MAP_PRIVATE:
		 A call	to mmap() for a	shared memory object when
		 MAP_PRIVATE is	specified and the implementation does
		 not support this functionality	shall return
		 MAP_FAILED and	set errno to ENOTSUP.

	  30   If neither _POSIX_MAPPED_FILES nor
	       _POSIX_SHARED_MEMORY_OBJECTS is defined and the
	       implementation does not support the mmap() function as
	       defined in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() shall	return MAP_FAILED and set
		 errno to ENOSYS.

	  31   If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation supports MAP_FIXED:
		 A call	to mmap() for a	shared memory object when
		 MAP_FIXED is specified	and the	range [addr,addr+len]
		 exceeds that allowed for the address space of a
		 process shall return MAP_FAILED and set errno to
		 ENOMEM.

     Untestable	Aspects
	  1    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() for a	shared memory object when addr
		 is not	0 shall	cause the system to place the memory
		 object	near addr and when addr	is 0 the system	shall
		 have freedom to place the object anywhere.
		 Reason	for omission: Specification is inadequate for
		 testing.

	  2    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 Updating of the st_ctime and st_mtime fields of a
		 file mapped by	a call to mmap() for a shared memory
		 object	with MAP_SHARED	set in flags and PROT_WRITE
		 set in	prot when a write reference occurs to a	mapped
		 region	and no call to msync is	made.
		 Reason	for omission: No portable way to induce	this



     Page 7					    (printed 2/21/103)






     mmap(LSB.os/mfiles)  LSB-OS (The Open Group)  mmap(LSB.os/mfiles)



		 condition.

	  3    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() for a	shared memory object when the
		 mapping could not be locked in	memory,	if required by
		 mlockall(), due to a lack of resources	shall return
		 MAP_FAILED and	set errno to EAGAIN.
		 Reason	for omission: No portable test method for this
		 assertion.

	  4    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation supports MAP_FIXED:
		 A call	to mmap() for a	shared memory object when addr
		 is not	a multiple of the page size and	MAP_FIXED is
		 specified shall return	MAP_FAILED and set errno to
		 EINVAL.
		 Reason	for omission: The specification	is inadequate
		 for testing as	it does	not specify the	conditions
		 under which this error	will occur.

	  5    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() for a	shared memory object when off
		 is not	a multiple of the page size shall return
		 MAP_FAILED and	set errno to EINVAL.
		 Reason	for omission: The specification	is inadequate
		 for testing as	it does	not specify the	conditions
		 under which this error	will occur.

	  6    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() for a	shared memory object when
		 MAP_FIXED is not specified and	there is insufficient
		 room in the address space of the process to effect
		 the mapping shall return MAP_FAILED and set errno to
		 ENOMEM.
		 Reason	for omission: There is no portable test	method
		 for this assertion.

	  7    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5:
		 A call	to mmap() for a	shared memory object when
		 addresses in the range	[off, (off+len)] are invalid
		 for the object	specified by fildes shall return
		 MAP_FAILED and	set errno to ENXIO.



     Page 8					    (printed 2/21/103)






     mmap(LSB.os/mfiles)  LSB-OS (The Open Group)  mmap(LSB.os/mfiles)



		 Reason	for omission: There is no portable test	method
		 for this assertion.

	  8    If _POSIX_SHARED_MEMORY_OBJECTS is defined or the
	       implementation supports the mmap() function as defined
	       in System Interfaces and	Headers, Issue 5 and the
	       implementation supports MAP_FIXED:
		 A call	to mmap() for a	shared memory object when
		 MAP_FIXED is specified	in flags and the combination
		 of addr, len and off are invalid for the object
		 specified by fildes shall return MAP_FAILED and set
		 errno to ENXIO.
		 Reason	for omission: There is no portable test	method
		 for this assertion.

     RELEASE
	  Release LSB-OS
	  Copyright (c)	1997 X/Open Company Ltd., A member of The Open
	  Group.
	  All rights reserved



































     Page 9					    (printed 2/21/103)



