Date: Sat, 4 Jul 2009 17:40:19 -0700 (PDT) From: Nate Eldredge <neldredge@math.ucsd.edu> To: Alexander Best <alexbestms@math.uni-muenster.de> Cc: freebsd-hackers@freebsd.org Subject: Re: mmap/munmap with zero length Message-ID: <Pine.GSO.4.64.0907041735580.4747@zeno.ucsd.edu> In-Reply-To: <permail-20090704224845f0889e84000046f1-a_best01@message-id.uni-muenster.de> References: <permail-20090704224845f0889e84000046f1-a_best01@message-id.uni-muenster.de>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 5 Jul 2009, Alexander Best wrote: > i'm wondering why mmap and munmap behave differently when it comes to a length > argument of zero. allocating memory with mmap for a zero length file returns a > valid pointer to the mapped region. > > munmap however isn't able to remove a mapping with no length. > > wouldn't it be better to either forbid this in mmap or to allow it in munmap? POSIX has an opinion: http://www.opengroup.org/onlinepubs/9699919799/functions/mmap.html "If len is zero, mmap() shall fail and no mapping shall be established." http://www.opengroup.org/onlinepubs/9699919799/functions/munmap.html "The munmap() function shall fail if: ... [EINVAL] The len argument is 0." -- Nate Eldredge neldredge@math.ucsd.edu
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.4.64.0907041735580.4747>