Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

getpagesize(2)

getsysinfo(2)

mmap(2)

munmap(2)

Name

munmap − unmaps memory of a character device

Syntax

#include <sys/types.h>
#include <sys/mman.h>

 caddr_t munmap(addr, len)
caddr_t addr;
size_t len;

Arguments

addr Specifies the address space of the calling process at which the unmapping begins. 

len Specifies the number of bytes to unmap. 

Description

The munmap system call unmaps a specified number of bytes (len) starting at a specified address (addr) from the address space of the calling process.  You mapped this device in a previous call to mmap. Subsequent access to the unmapped region results in a SIGSEGV signal. You cannot unmap data, stack, and text segments using munmap.

The munmap system call rounds len to the nearest multiple of page size as returned by getpagesize.

The range [addr, addr + len] may contain more than one mapped region created by mmap. In this case, munmap unmaps all of the mapped regions.

Restrictions

All of the mapped regions must be wholly contained in the range [addr, addr + len].  That is, addr must be the beginning of some mapped region and addr + len must be the end of some (possibly different) mapped region. 

Return Value

If successful, munmap returns 0. Otherwise, it returns −1 and sets the errno argument to one of the errors listed in the Diagnostics section. 

Diagnostics

The call to munmap fails if one or more of the following is true:

[EINVAL] The address you specified in addr is not a multiple of the page size as returned by getsysinfo.

[EINVAL] The addresses in the range [addr, addr + len] are not valid in the process address space. 

[EINVAL] All of the segments being unmapped are not entirely contained in the range [addr, addr + len]. 

See Also

getpagesize(2), getsysinfo(2), mmap(2)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026