From: Eric Dumazet <eric.dumazet@gmail.com>
To: "Sébastien Paumier" <sebastien.paumier@univ-mlv.fr>
Cc: linux-kernel@vger.kernel.org
Subject: Re: mmap
Date: Fri, 02 Dec 2011 15:45:27 +0100 [thread overview]
Message-ID: <1322837127.2762.11.camel@edumazet-laptop> (raw)
In-Reply-To: <4ED8C275.7020907@univ-mlv.fr>
Le vendredi 02 décembre 2011 à 13:20 +0100, Sébastien Paumier a écrit :
> Hi,
> I have a question about mmap's behavior when one tries to map a file asking for
> a length greater than the actual file size. When I run the attached code on a
> 100 bytes file, I have the following output:
>
> (... file content followed by zeros...)
> n=4096
> write: Bad address
>
> So, it seems that the actual memory area provided by mmap is one page large and
> not the requested length of filesize+10000. I guess that 'write' writes less
> than requested because it was interrupted by the SIGBUS signal. And my question is:
>
> shouldn't mmap either complain about the requested length or provide an
> accessible area of the requested length, instead of silently failing ?
Accessing non existing memory leads to SIGBUS signal, not a silent
failure. Its documented behavior.
man mmap
SIGBUS Attempted access to a portion of the buffer that does not corre‐
spond to the file (for example, beyond the end of the file,
including the case where another process has truncated the
file).
next prev parent reply other threads:[~2011-12-02 14:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-02 12:20 mmap Sébastien Paumier
2011-12-02 14:45 ` Eric Dumazet [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-07-02 14:00 mmap mdaljeet
2001-07-03 17:47 ` mmap Jens Axboe
2001-05-15 10:08 mmap mdaljeet
2001-05-15 6:47 mmap mdaljeet
2001-05-15 7:33 ` mmap Gerd Knorr
2001-05-15 9:42 ` mmap Alan Cox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1322837127.2762.11.camel@edumazet-laptop \
--to=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sebastien.paumier@univ-mlv.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®